#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll f[1000000];
int main()
{
ll t, n, i, j = 1;
cin >> t;
while(t--)
{
cin >> f[0] >> f[1] >> f[2] >> f[3] >> f[4] >> f[5] >> n;
for(i=0;i<6;i++)
{
f[i] = f[i] % 10000007;
}
for(i=6;i<=n;i++)
{
f[i] = f[i-1] + f[i-2] + f[i-3] + f[i-4] + f[i-5] + f[i-6];
f[i] = f[i]%10000007;
}
cout << "Case " << j++ << ": " << f[n] << "\n";
}
return 0;
}
#define ll unsigned long long int
using namespace std;
ll f[1000000];
int main()
{
ll t, n, i, j = 1;
cin >> t;
while(t--)
{
cin >> f[0] >> f[1] >> f[2] >> f[3] >> f[4] >> f[5] >> n;
for(i=0;i<6;i++)
{
f[i] = f[i] % 10000007;
}
for(i=6;i<=n;i++)
{
f[i] = f[i-1] + f[i-2] + f[i-3] + f[i-4] + f[i-5] + f[i-6];
f[i] = f[i]%10000007;
}
cout << "Case " << j++ << ": " << f[n] << "\n";
}
return 0;
}
Comments
Post a Comment