thecodecird

Neeraj & Stair

Sep 27th, 2021
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2.  
  3. #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  4.  
  5. #define ll long long int
  6.  
  7. #define pb push_back
  8.  
  9. #define f(a) for(ll i = 0;i<a;i++)
  10.  
  11. #define ffor(i,a,b) for(ll i = a;i<b;i++)
  12.  
  13. #define rfor(i,a,b) for(ll i = a;i>b;i--)
  14.  
  15. #define sll set<ll>
  16.  
  17. #define mll map<ll,ll>
  18.  
  19. #define vll vector<ll>
  20.  
  21. #define T ll t; cin>>t; while(t--)
  22.  
  23. #define MOD 1000000007
  24.  
  25. using namespace std;
  26.  
  27. ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
  28.  
  29. ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
  30.  
  31. ll modpower(ll x,ll y,ll m){if(y==0)return 1;ll p=modpower(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
  32.  
  33.  
  34. int main()
  35.  
  36. {
  37.  
  38.     faster
  39.  
  40.     ll dp[100005];
  41.  
  42.     dp[0]=0;
  43.  
  44.     dp[1]=1;
  45.  
  46.     dp[2]=2;
  47.  
  48.     for(ll i=3;i<100005;i++)
  49.         dp[i]=(dp[i-1]+dp[i-2])%1000000007;
  50.  
  51.     T
  52.  
  53.     {
  54.         ll n;
  55.  
  56.         cin>>n;
  57.  
  58.         cout<<dp[n]<<"\n";
  59.  
  60.     }
  61.  
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment