Strange behaviour of Codeforces C++ compiler

Revision en3, by invinciblerm, 2016-08-21 12:19:41

I have written the following code for http://codeforces.net/problemset/problem/552/C

include<bits/stdc++.h>

using namespace std; typedef long long ll;

int main() { int i,j,k,l,m,n,w,f=0,t; cin>>w>>m;

while(m)
{
    i=m%w;
    m=m/w;
    if(f==1)
    i++;
    f=0;
    if(i==0 || i==1 || i==w)
    {  
    }
    else if(i==w-1)
    {
       f=1;
    }
    else
    {
       cout<<"NO";
       return 0;
    }
}
cout<<"YES";
return 0;

} Image link http://codeforces.net/predownloaded/57/61/5761486604e2ca57814ada50f20e298c3a8c764b.png

Test Case is: 116 Time: 15 ms, memory: 2020 KB Verdict: WRONG_ANSWER Input 10 899 Participant's output NO Jury's answer YES Checker comment wrong answer expected YES, found NO

****

This code is working fine on my DEV C++ Compiler but is giving WA on test case 116 on codeforces , but I have tried that test case on my machine and its showing the right output.

Can anyone explain the reason behind this strange behaviour?

Tags meet-in-the-middle, brute force, greedy, math, dp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English invinciblerm 2016-08-21 12:19:41 2 Tiny change: ',l,m,n,w,f,t;\n cin>' -> ',l,m,n,w,f=0,t;\n cin>'
en2 English invinciblerm 2016-08-21 11:14:01 22
en1 English invinciblerm 2016-08-21 11:13:15 1027 Initial revision (published)