Advertisement
MiinaMagdy

11933 - Splitting Numbers

Sep 11th, 2022
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define endl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(), x.end()
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  12.     int n;
  13.     while (scanf("%d", &n), n) {
  14.         int a[2]{};
  15.         for (int i = 0, idx = 0; i < 32; i++) {
  16.             if (n & (1 << i)) {
  17.                 a[idx++ % 2] |= (1 << i);
  18.             }
  19.         }
  20.         cout << a[0] << " " << a[1] << endl;
  21.     }
  22. }
  23.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement