matheus_monteiro

Ponto do Meio

Aug 20th, 2021 (edited)
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. int32_t main() {
  6.  
  7.     ios_base::sync_with_stdio(false);
  8.     cin.tie(nullptr);
  9.  
  10.     int n;
  11.     cin >> n;
  12.  
  13.     __int128_t f = 1, v = 4, a = 4;
  14.  
  15.     while(n--) {
  16.         v = v + a + f;
  17.         f *= 4;
  18.         a = v + f - 1;
  19.     }
  20.  
  21.     vector<int> ans;
  22.  
  23.     while(v) {
  24.         ans.push_back(v % 10);
  25.         v /= 10;
  26.     }
  27.  
  28.     for(int i = (int)ans.size() - 1; i >= 0; i--)
  29.         cout << ans[i];
  30.     cout << endl;
  31.  
  32.     return 0;
  33. }
Add Comment
Please, Sign In to add comment