Advertisement
Eather

11933

Jul 13th, 2011
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cmath>
  5. #include<cstdlib>
  6. #include<algorithm>
  7. #include<vector>
  8. #include<bitset>
  9. #include<set>
  10. #include<map>
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.    int n,a,b,c,t;
  16.  
  17.     while(scanf("%d",&n)&&n)
  18.     {
  19.         a=c=0,t=1;b=n;
  20.         while(b)
  21.         {
  22.             //cout<<"b="<<b<<" a="<<a<<" t="<<t<<" c="<<c<<endl;
  23.             if(b&1)
  24.             {
  25.                 c++;
  26.                 if(c&1)a=a|t;
  27.             }
  28.             t=t<<1;
  29.             b=b>>1;
  30.  
  31.         }
  32.         b=n-a;
  33.         printf("%d %d\n",a,b);
  34.     }
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement