C++ Different Outputs in IDE and CodeForces Judge

Revision en1, by mshereef, 2021-08-24 01:53:12

I was solving this problem Odd Divisor and when I tested it using the sample test cases it produced the correct output in my IDE, however when I submit the code, it produces a different output with the sample test case and so gives a wrong answer on test 1.

Here's the code:

#include <iostream>
#include <string>
using namespace std;


long t, x;
int main(){


    cin >>t;
    while(t--){
        cin>>x;
        if(x%2==1)cout<<"YES";
        else{
            bool f=false;
            while(x>1){
                if((x/2)%2==1&&(x/2)!=1){
                    f=true;
                    break;
            }
            x/=2;
        }
        if(f)cout<<"YES";
        else cout<<"NO";
    }
    cout<<"\n";
}
return 0;
}

If anyone knows why this is happening, I would really appreciate the help.

Tags #c++

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English mshereef 2021-08-24 01:53:12 956 Initial revision (published)