Advertisement
smatskevich

Solutions4

Jan 10th, 2022
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cmath>
  3. #include <iostream>
  4. #include <map>
  5. #include <set>
  6. #include <string>
  7. #include <tuple>
  8. #include <unordered_map>
  9. #include <unordered_set>
  10. #include <vector>
  11.  
  12. typedef long long ll;
  13. typedef unsigned long long ull;
  14. using namespace std;
  15.  
  16. // Святослав и КЦ
  17. int main() {
  18.   ios::sync_with_stdio(false);
  19.   cin.tie(nullptr);
  20.  
  21.   int n = 0, x = 0;
  22.   cin >> n >> x;
  23.   ull result = 1;
  24.   --x;
  25.   --n;  // Максимальная степень двойки, которую можем использовать.
  26.   while (x > 0) {
  27.     result += 1ull << n;
  28.     --n;
  29.     --x;
  30.   }
  31.  
  32.   cout << result << endl;
  33.   return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement