SHARE
TWEET

lightoj - 1006 - Hex-a-bonacci

jakaria_hossain Jul 31st, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long ara[1000000];
  4. long long a, b, c, d, e, f;
  5.  long long fn( long long n ) {
  6.     for(int i=0;i<=n;i++)
  7.     {
  8.         if(i==0)ara[i]=a;
  9.         else if(i==1)ara[i]=b;
  10.         else if(i==2)ara[i]=c;
  11.         else if(i==3)ara[i]=d;
  12.         else if(i==4)ara[i]=e;
  13.         else if(i==5)ara[i]=f;
  14.         else ara[i]=ara[i-1]+ara[i-2]+ara[i-3]+ara[i-4]+ara[i-5]+ara[i-6];
  15.         ara[i] = ara[i] % 10000007;
  16.  
  17.     }
  18.     return ara[n];
  19. }
  20. int main() {
  21.     long long n, caseno = 0, cases;
  22.     cin>>cases;
  23.     while( cases-- ) {
  24.         cin>>a>>b>>c>>d>>e>>f>>n;
  25.         cout<< "Case "<<++caseno<< ": "<<fn(n) % 10000007<<endl;
  26.     }
  27.     return 0;
  28. }
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