Блог пользователя mshereef

Автор mshereef, история, 5 лет назад, По-английски

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.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

use long long instead of long