SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int dp[10000];
  4.  
  5. int a, b, c, d, e, f;
  6. int fn( int n ) {
  7.     dp[0]=a;
  8.     dp[1]=b;
  9.     dp[2]=c;
  10.     dp[3]=d;
  11.     dp[4]=e;
  12.     dp[5]=f;
  13.     for(int i=6; i<=n; i++) {
  14.         dp[i]=(dp[i-1]+dp[i-2]+dp[i-3]+dp[i-4]+dp[i-5]+dp[i-6])%10000007;
  15.     }
  16.     return dp[n];
  17. }
  18. int main() {
  19.     int n, caseno = 0, cases;
  20.     scanf("%d", &cases);
  21.     while( cases-- ) {
  22.         scanf("%d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &n);
  23.         printf("Case %d: %d\n", ++caseno, fn(n) % 10000007);
  24.     }
  25.     return 0;
  26. }
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