#include<stdio.h>
int main(){
long int n;
long int i=5;
long int z=0,j=0;
int testCase;
scanf("%d",&testCase);
for(j=0;j<testCase;j++){
scanf("%d",&n);
for(;n/i!=0;i*=5){
z+=n/i;
}
printf("%d\n",z);
z=0;
i=5;
}
return 0;
}
I have checked the output corresponding to different inputs in codeblocks and it showed correct output but codechef shows wrong answer. PLease help me to find my mistake.
You are using wrong specifiers. %d is for int variables ONLY. This mismatch of specifiers in scanf and printf is causing your program to print garbage value. Fix this and you will get an AC.
I think the mistake is in the test case where the number is greater than the range of int since you are using %d instead of %lld in your code. For a better explanation, you can check my
[1].
Hope this helps!
[1]: https://www.codechef.com/viewsolution/8970982
What decides your verdict is how your code runs in codechef environment. Your PC might make adjustments, give a more friendly environment to your code. But here it might be different.
Hey @namanjn, if you believe that your question is answered please mark it as answered otherwise it’ll appear on CodeChef discuss unanswered question. Thanks.