Advertisement
tuki2501

MAXARR1.cpp

Sep 14th, 2022
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     cin.tie(0)->sync_with_stdio(0);
  6.     const int N = 100000;
  7.     vector<int> a(N + 2);
  8.     a[0] = 0;
  9.     a[1] = 1;
  10.     for (int i = 1; i * 2 <= N; i++) {
  11.         a[i * 2] = a[i];
  12.         a[i * 2 + 1] = a[i] + a[i + 1];
  13.     }
  14.     for (int i = 1; i <= N; i++) {
  15.         a[i] = max(a[i], a[i - 1]);
  16.     }
  17.     int T; cin >> T;
  18.     while (T--) {
  19.         int n; cin >> n;
  20.         cout << a[n] << '\n';
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement