LightOJ - 1006 - Hex-a-bonacci
Statment
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%I64d",&a)
#define sff(a,b) scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c) scanf("%I64d %I64d %I64d",&a,&b,&c)
#define sffl(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e) scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define ll long long
#define MAX 1000009
#define Max 100000000009
#define pb push_back
#define all(c) c.begin(),c.end()
#define mset(a,b) memset(a,b,sizeof(a))
#define MOD 10000007
#define ff first
#define sc second
int main()
{
ll dp[10009];
vector<ll>a;
ll c;
scanf("%lld",&c);
for(ll j=1; j<=c; j++)
{
a.clear();
mset(dp,0);
ll n,x;
ll i;
for(i=0; i<6; i++)
{
scanf("%lld",&x);
a.pb(x);
}
scanf("%lld",&n);
dp[0]=a[0]%MOD;
for(i=1; i<6; i++)
dp[i]=a[i]%MOD;
for(i=6; i<=n; i++)
dp[i]=(dp[i-1]%MOD+dp[i-2]%MOD+dp[i-3]%MOD+dp[i-4]%MOD+dp[i-5]%MOD+dp[i-6]%MOD)%MOD;
printf("Case %lld: %lld\n",j,dp[n]);
}
}
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন