Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long t,i=0;
- cin>>t;
- while(t--){
- i++;
- long long n,x,j=0,total=0,l;
- cin>>n;
- vector<int>bin;
- while(n){
- x=n%2;
- bin.push_back(x);
- n/=2;
- j++;
- }
- x=0;
- bin.push_back(x);
- reverse(bin.begin(),bin.end());
- next_permutation(bin.begin(),bin.end());
- cout<<"Case "<<i<<": ";
- l=0;
- for(int k=j;k>=0;k--){
- total+=(bin[k]*pow(2,l));
- l++;
- }
- cout<<total<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement