-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10844.c
38 lines (30 loc) · 836 Bytes
/
10844.c
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
#include <stdio.h>
long long a[101][10];
long long s[101];
int main() {
int n;
scanf("%d", &n);
a[1][0] = 0;
for (int i = 1; i < 10; i++) {
a[1][i] = 1;
s[1] ++;
}
for (int i = 2; i <= n; i++) {
if (i == 2)
a[i][1] = 2;
else
a[i][1] = (a[i - 2][1] + a[i - 1][2]) % 1000000000;
a[i][2] = (a[i - 1][1] + a[i - 1][3]) % 1000000000;
a[i][3] = (a[i - 1][2] + a[i - 1][4]) % 1000000000;
a[i][4] = (a[i - 1][3] + a[i - 1][5]) % 1000000000;
a[i][5] = (a[i - 1][4] + a[i - 1][6]) % 1000000000;
a[i][6] = (a[i - 1][5] + a[i - 1][7]) % 1000000000;
a[i][7] = (a[i - 1][6] + a[i - 1][8]) % 1000000000;
a[i][8] = (a[i - 1][7] + a[i - 1][9]) % 1000000000;
a[i][9] = a[i - 1][8] % 1000000000;
for (int j = 1; j <= 9; j++)
s[i] += a[i][j] % 1000000000;
}
printf("%lld", s[n] % 1000000000);
return 0;
}