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.
use long long instead of long
it worked thank you so much, do you have any idea why that happens though?
If you want to be sure of how large your type is, you can use
int64_t
instead oflong long
.