一道数学题
首先分类讨论。
当 时:
,直接输出 No! 即可。
cout << "No!\n";
当 是奇数时:
是偶数。 所以输出 即可。
cout << 1 << '\n';
当 是非零偶数时:
我们要使 。
当 是奇数时, 当 时,,我们求 是 的几次幂即可。
最后附上代码:
#include<bits/stdc++.h>
using namespace std;
int T;
long long x;
double a;
long long u;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--){
cin>>x;
if(x==0){
cout<<"NO!\n";
continue;
}
if(x%2) cout<<1<<'\n';
else{
int s=0;
while(x){
if(x%2) break;
s++;
x/=2;
}
cout<<s+1<<'\n';
}
}
return 0;
}