SHARE
TWEET

Untitled

a guest Feb 23rd, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define uskoritel ios_base::sync_with_stdio(false); cin.tie(0);
  6. #define pb push_back
  7. #define x first
  8. #define y second
  9. typedef pair <int, int> pii;
  10.  
  11. long long int ne;
  12. vector <long long int> an;
  13. vector <int> ans;
  14.  
  15. long long int func(long long int n){
  16.     if (an[n] != 0) return an[n];
  17.     if (n <= 2){
  18.         an[n] = 1;
  19.         return an[n];
  20.     }
  21.     else if (n%2 == 1){
  22.         an[n] = func(6*n / 7) + func(2*n/3);
  23.         return an[n];
  24.     }
  25.     else if (n%2 == 0){
  26.         an[n] = func(n-1) + func(n-3);
  27.         return an[n];
  28.     }
  29. }
  30.  
  31. int main(){
  32.     uskoritel
  33.     cin >> ne;
  34.     an.resize(ne+1);
  35.     fill(an.begin(), an.end(), 0);
  36.  
  37.     cout << func(ne) % (long long int)(pow(2, 32));
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top