# why is this solution shown wrong to the FCTRL problem?

#include<stdio.h>
int main()
{
unsigned int i,n,s=0;
scanf("%u",&n);
unsigned int t[n];
for(i=0;i<n;i++)
{
scanf("%u",&t[i]);
}
for(i=0;i<n;i++)
{
if(t[i]>=5)
{
while(t[i]>=5)
{
t[i]=t[i]/5;
s=t[i]+s;
}
}
else
{
s=0;
}
t[i]=s;
}
for(i=0;i<n;i++)
{
printf("%u\n",t[i]);
}
return 0;
`` }

The issue is your condition to reset the value of variable s, once you calculate the answer, you need not accumulate it in the variable. That will certainly give you incorrect answers.
Your code doesn’t even run on the given sample cases.
Kindly use the sample input and output on the code first.

Or still if you feel stuck,
Observe the output of
2
5
5

The output should be same for both the cases. Which is not the case with your code. Also refer to the editorial if still you don’t get it.

1 Like

You are not resetting s after calculating the last answer.

Meaning, you calculated s=14 for 60. Now after this, you should reset value of S =0, which you havent done. Due to this, in your next step, the calculation goes like-

For next value X=100

S=(t[i]+s)=14+100/5=34 instead of S=100/5+0=20

You are printing 38 instead of 24 for 100, the 14 of X=60 is carried over here.

1 Like

28 seconds lol. XD

Indeed, very close XD

1 Like

thanks for helping me out!