-
Notifications
You must be signed in to change notification settings - Fork 34
/
1006-Hex-a-bonacci.cpp
77 lines (60 loc) · 914 Bytes
/
1006-Hex-a-bonacci.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>
#include <iostream>
using namespace std;
long long t;
long long a;
long long b;
long long c;
long long d;
long long e;
long long f;
long long n;
long long x[10005];
int fn( int n ) {
for (int i = 0; i <= n; i++) {
if( i == 0 ) {
x[i] = a;
continue;
}
if( i == 1 ) {
x[i] = b;
continue;
}
if( i == 2 ) {
x[i] = c;
continue;
}
if( i == 3 ) {
x[i] = d;
continue;
}
if( i == 4 ) {
x[i] = e;
continue;
}
if( i == 5 ) {
x[i] = f;
continue;
}
x[i] = x[i-1] + x[i-2] + x[i-3] + x[i-4] + x[i-5] + x[i-6];
x[i] = x[i] % 10000007;
}
return x[n];
}
int main()
{
long long ans;
cin >> t;
for (long long i = 1; i <= t; i++) {
cin >> a;
cin >> b;
cin >> c;
cin >> d;
cin >> e;
cin >> f;
cin >> n;
ans = fn(n);
ans = ans % 10000007;
cout << "Case "<< i <<": "<< ans << endl;
}
}