Advertisement
Guest User

Untitled

a guest
Jul 26th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. // 2021
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. //constant define things
  6.  
  7. #define pb(a) push_back(a);
  8. #define pf(a) push_front(a);
  9.  
  10. #define ff first
  11. #define ss second
  12.  
  13. #define all(s) s.begin(),s.end()
  14.  
  15. #define pii pair<int,int>
  16. #define pll pair<long,long>
  17.  
  18. bool isVowel(char a){
  19.     a=tolower(a);
  20.     return (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'?true:false);
  21. }
  22. double find_dist(int x1,int y1,int x2,int y2){
  23.     return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  24. }
  25. int to_int(string s){
  26.     // stoi() ->function to int up to 9.2.0 versions
  27.     int n=0,i=0;
  28.     if(s[0]=='-')i=1;
  29.     for(;i<(int)s.size();i++) n=n*10+(int(s[i])-48);
  30.     if(s[0]=='-')n*=-1;
  31.     return n;
  32. }
  33. string to_str(int X){
  34.     // bug is that -9123 is not works because of sign '-'
  35.     //to_string() -> function for c++ 17
  36.     string ANS="";
  37.     while(X>0){
  38.         ANS+=(X%10)+'0';
  39.         X/=10;
  40.     }
  41.     reverse(ANS.begin(),ANS.end());
  42.     return ANS;
  43. }
  44. int BinaryToDecimal(int x){
  45.     int cnt=0,ans=0;
  46.     while(x>0){
  47.         if(x%10==1){
  48.             ans+=pow(2,cnt);
  49.         }
  50.         x/=10;
  51.         cnt++;
  52.     }
  53.     return ans;
  54. }
  55. string decimalTObinary(int n) {
  56.     string s="";
  57.     if(n==0)return 0;
  58.     else{
  59.         for(int i=0;n>0;i++){
  60.             s+=((n%2)+'0');
  61.             n/=2;
  62.         }
  63.         return s;
  64.     }
  65. }
  66. bool isPrime(int x){
  67.     for(int i=2;i<=sqrt(x);i++){
  68.         if(x%i==0){
  69.             return false;
  70.         }
  71.     }
  72.     return true;
  73. }
  74. int gcd(int a,int b){
  75.     if(a==0) return b;
  76.     return gcd(b%a,a);
  77. }
  78. int lcm(int a,int b){
  79.     return a*(b/gcd(a,b));
  80. }
  81. vector<int>All_Factors(int n){
  82.     vector<int>factors;
  83.     for(int i=1;i<=sqrt(n);i++){
  84.         if(n%i==0){
  85.             factors.push_back(i);
  86.             if(i!=n/i){
  87.                 factors.push_back(n/i);
  88.             }
  89.         }
  90.     }
  91.     return factors;
  92. }
  93. // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  94.  
  95. #define int long long
  96. const int N=2e4,INF=1e9+7;
  97. vector<int>dp(101,0);
  98.  
  99. int FFF(int x){
  100.     if(x==1)return 2;
  101.     if(x==2)return 3;
  102.     if(x==3)return 5;
  103.    
  104.     if(dp[x])return dp[x];
  105.     return dp[x]=FFF(x-1)+FFF(x-2);
  106. }
  107. void bbb(){
  108.     int n;
  109.     cin>>n;
  110.     cout<<FFF(n);
  111. }
  112. signed main(){
  113.     ios_base::sync_with_stdio(false); cin.tie(nullptr);cin.tie(nullptr);
  114.     int test_cases=1;
  115.     //cin>>test_cases;
  116.     while(test_cases-->0){
  117.         bbb();
  118.     }
  119.     return 0;
  120. }
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement