yordanganev

pc2017A

May 5th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     ios_base::sync_with_stdio(false);
  7.     int x, y, z;
  8.  
  9.     while (cin >> x >> y >> z) {
  10.         x >>= z;
  11.        
  12.         int reverse = 0;
  13.  
  14.         for (int i = 0; i < y; i++) {
  15.             int thisBit = !(x % 2);
  16.             reverse += thisBit << i;
  17.             x >>= 1;
  18.         }
  19.  
  20.         cout << reverse << endl;
  21.  
  22.     }
  23.  
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment