Joao_Joao

Dice Combinations - C++

Sep 27th, 2020 (edited)
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;typedef long double llf;typedef double fl;typedef string str;typedef pair<double, double> dd;
  5. typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<fl> vf;typedef vector<ll> vl;
  6. typedef vector<llf> vlf;typedef vector<char> vc;typedef vector<str> vs;typedef pair<int,int> ii;
  7. # define f(i,a,b,c) for(ll i=a;i<b;i+=c)
  8. # define fd(i,a,b,c) for(ll i=a;i>=b;i-=c)
  9. # define w(x) while(x--)
  10. # define ctoi(a) (a-'0')
  11. # define pb push_back
  12. # define eb emplace_back
  13. # define lb lower_bound
  14. # define ub upper_bound
  15. # define be(x) x.begin(), x.end()
  16. # define rbe(x) x.rbegin(), x.rend()
  17. # define _(x) ios::sync_with_stdio(0);cin.tie(0);cout.precision(x);cout.setf(ios::fixed);
  18.  
  19. ll n, memo[1000010];
  20. ll dp(ll x){
  21.     if(x<0)return 0;
  22.     if(x==1 or x==0)return 1;
  23.     if(memo[x])return memo[x]%int(1e9+7);
  24.     return memo[x]=dp(x-1)+dp(x-2)+dp(x-3)+dp(x-4)+dp(x-5)+dp(x-6);
  25. }
  26. int main(){_(0)
  27.     cin>>n;
  28.     cout<<dp(n)%int(1e9+7)<<'\n';
  29. return 0;}
RAW Paste Data Copied