Help me in solving LBCC21 problem

My issue

My code

#include <stdio.h>

int main() 
{
    int t;
    scanf("%d", &t); 
    while (t--)
    {
        int P, score100, score1, problems_solved;
        scanf("%d", &P);
        score100 = P / 100;
        score1 = P % 100;
        problems_solved = (score100) + (score1/10);
        if (score1 % 10 == 0 && problems_solved <= 10) 
        {
            int problems_solved_new = problems_solved + score1;
            printf("%d\n", problems_solved_new);
        } else 
        {
            printf("-1\n");
        }
    }
    return 0;
}


Learning course: Solve Programming problems using C
Problem Link: CodeChef: Practical coding for everyone

@njyotirvinay
few mistakes i have corrected it in your code.

include <stdio.h>

int main()
{
int t;
scanf(β€œ%d”, &t);
while (t–)
{
int P, score100, score1, problems_solved;
scanf(β€œ%d”, &P);
score100 = P / 100;
score1 = P % 100;
problems_solved = (score100) + score1;
if ( problems_solved <= 10)
{
int problems_solved_new = problems_solved ;
printf(β€œ%d\n”, problems_solved_new);
} else
{
printf(β€œ-1\n”);
}
}
return 0;
}

thanks it works but during submission it still says wrong answer

@njyotirvinay
can u send me the code for which u r getting wrong answer

for the code you have changed it’s still getting wrong answer. I’ve even tried in multiple ways but it still says wrong answer.

@njyotirvinay

#include<stdio.h>

int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int P, score100, score1, problems_solved;
scanf("%d", &P);
score100 = P / 100;
score1 = P % 100;
problems_solved = (score100) + score1;
if ( problems_solved <= 10)
{
int problems_solved_new = problems_solved ;
printf("%d\n", problems_solved_new);
} else
{
printf("-1\n");
}
}
return 0;
}

actually the thing is when i’m sending it its making some changes like in printf and scanf " " and instead of t-- in while loop its making t- only that is why its making error.
for more clarity please refer this its the same code ss.

hey thanks for the help and i’ve noticed those errors and i’ve corrected them, the actual thing is either with the time complexity or the ide bug. thanks for the help

1 Like