https://www.codechef.com/viewsolution/31011404
Why am i getting WA in this .Help needed.
Did you run your code? Your code printed all 100s for sample input.
Thats because of this line-
for(int i=1;i<101;i++)
{
if(v[i]==0);
ans++;
}
In if(v[i]==0);
you have put a ;
after if, indicating that the body of if statement is empty. Hence, ans++ gets executed no matter what. Remove it and you should get AC.
4 Likes
@vijju123
you are right for every test case
@samarth2001 your’s ans would be 100 so before submitting run Yours codes on pc it might helps a lot.