Enormous input Test Code question

Here is the link to the question asked:

http://ww2.codechef.com/problems/INTEST/

This is my code for the solution:

    #include<iostream>
typedef long long ll;

using namespace std;
int main()
{
ll n,k,t;
ll count=0;
scanf("%lld  %lld",&n,&k);

while(n--)
{
   scanf("%lld",&t);
 if(t%k==0)
        count++;
}
printf("%lld\n",count);
return 0;


}

Now I can’t seem to understand why this code is producing a WRONG ANSWER as the result. I checked some successful submissions. The AC codes I viewed are almost the same. Then why does this code produce an error?

@piy9

the code you have typed above gets accepted just copy and paste it and it will be accepted with 5.55 sec runtime

http://ww2.codechef.com/viewsolution/2119793

on the other hand your previous submissions which are not accepted are having a problem that you have declared count as integer type and not ll

and then you are doing printf with ll type.

@v_akshary => if your analysis is right then code shouldn’t compile rather than giving wrong answer

2 Likes

Yes thank you it did solve my problem. But like the edit mentions: why is the code getting compiled in the first place instead of showing a wrong answer?

//