Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- using namespace std;
- long long dp[10004];
- long long a,b,c,d,e,f;
- long long inf=10000007;
- long long myfunc(long long n)
- {
- if(n==0)
- return a;
- if(n==1)
- return b;
- if(n==2)
- return c;
- if(n==3)
- return d;
- if(n==4)
- return e;
- if(n==5)
- return f;
- if(dp[n]!=-1)
- return dp[n];
- else
- {
- return dp[n]=(myfunc(n-1)+myfunc(n-2)+myfunc(n-3)+myfunc(n-4)+myfunc(n-5)+myfunc(n-6))%inf;
- }
- }
- int main()
- {
- long long n,k,r,i,j=0,t;
- cin>>t;
- while(t--)
- {
- for(i=0; i<=10000; i++)
- dp[i]=-1;
- cin>>a>>b>>c>>d>>e>>f>>n;
- k=myfunc(n);
- printf("Case %lld: %lld\n",j+1,k%inf);
- j++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment