Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

invinciblerm's blog

By invinciblerm, history, 4 years ago, In English,

I have written the following code for http://codeforces.com/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.com/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?

Read more »

 
 
 
 
  • Vote: I like it
  • +9
  • Vote: I do not like it