Advertisement
Emiliatan

e305

Jul 5th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. /* e305           */
  2. /* AC (3ms, 64KB) */
  3. #include <cstdio>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. typedef short int16;
  9. typedef unsigned short uint16;
  10. typedef long long int64;
  11. typedef unsigned long long uint64;
  12. typedef unsigned int uint;
  13. typedef pair<int, int> pii;
  14.  
  15. int64 n, sum, ans;
  16. char ch, s[15];
  17. int16 index;
  18.  
  19. int main()
  20. {
  21.     while(true)
  22.     {
  23.         index = n = sum = 0;
  24.         ans = 1;
  25.         while((ch = getchar_unlocked()) && ch != '\n' && ch != EOF)
  26.             n = n * 10 + ch - '0';
  27.         if(ch == EOF)
  28.             break;
  29.        
  30.         if(n == 0)
  31.         {
  32.             putchar_unlocked('0');
  33.             putchar_unlocked('\n');
  34.             continue;
  35.         }
  36.        
  37.         while(n)
  38.             sum += !(n & 1), n >>= 1;
  39.         while(sum--)
  40.             ans <<= 1;
  41.  
  42.         while(ans)
  43.             s[index++] = ans % 10, ans /= 10;
  44.         while(index)
  45.             putchar_unlocked(s[--index] + '0');
  46.         putchar_unlocked('\n');
  47.     }
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement