#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n,test;
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n;
vector<ll>num;
while(n)
{
ll rem=n%2;
num.push_back(rem);
n=n/2;
}
num.push_back(0);
reverse(num.begin(),num.end());
l=num.size()-1;
next_permutation(num.begin(),num.end());
ll sum=0;
for(i=0,j=l;i<=l,j>=0;i++,j--)
{
sum+=num[i]*pow(2,j);
}
cout<<"Case "<<k<<": "<<sum<<endl;
}
return 0;
}
using namespace std;
typedef long long ll;
int main()
{
ll i,j,k,l,m,n,test;
cin>>test;
for(k=1;k<=test;k++)
{
cin>>n;
vector<ll>num;
while(n)
{
ll rem=n%2;
num.push_back(rem);
n=n/2;
}
num.push_back(0);
reverse(num.begin(),num.end());
l=num.size()-1;
next_permutation(num.begin(),num.end());
ll sum=0;
for(i=0,j=l;i<=l,j>=0;i++,j--)
{
sum+=num[i]*pow(2,j);
}
cout<<"Case "<<k<<": "<<sum<<endl;
}
return 0;
}
No comments:
Post a Comment