#include <bits/stdc++.h>
using namespace std;
int main()
{
long long int i,j,k,l,n,m,a[100000],d,b[100000],sum;
string s,st;
vector<string>v;
//freopen("1042.txt","r",stdin);
//freopen("1042out.txt","w",stdout);
cin>>n;
for(i=1;i<=n;i++)
{
sum=0;
cin>>m;
s.clear();
st.clear();
j=0;
while(m!=0)
{
a[j]=m%2;
m=m/2;
j++;
}
a[j]=0;
for(k=j;k>=0;k--)
{
st=a[k]+'0';
s=s+st;
}
next_permutation(s.begin(),s.end());
d=s.length()-1;
for(l=0;l<s.length();l++)
{
b[l]=s[l]-'0';
if(b[l]==1)
{
sum=sum+pow(2,d);
}
d--;
}
cout<<"Case "<<i<<": ";
cout<<sum<<endl;
}
return 0;
}
0 comments:
Post a Comment