https://ac.nowcoder.com/acm/contest/21763/B
根据式子可以发现,
f
(
x
)
f(x)
f(x) 代表的是
x
x
x 在二进制下 1 的个数。
根据二进制的性质,最早出现的显然是从低位到高位全部是 1 的情况,答案为
1
<
<
f
(
n
)
−
1
1<<f(n)-1
1<<f(n)−1。
#include<bits/stdc++.h>
#define endl '\n'
#define pii pair<int,int>
using namespace std;
using ll = long long;
ll f(ll n)
{
int ans=0;
while(n)
{
if(n&1)
ans++;
n>>=1;
}
return ans;
}
void solve()
{
ll n; cin>>n;
cout<<f(n)<<" "<<(1LL<<f(n))-1<<endl;;
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T; cin>>T;
while(T--)
solve();
return 0;
}