-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10844.cpp
More file actions
33 lines (24 loc) · 716 Bytes
/
10844.cpp
File metadata and controls
33 lines (24 loc) · 716 Bytes
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
#include <iostream>
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
long sum = 0;
long dp[n][10] = {0,};
for(int i=0; i<10;i++){
if(i == 0) dp[0][i] = 0;
else dp[0][i] = 1;
if(n == 1) sum += dp[0][i];
}
for(int i=1; i<n; i++){
for(int j=0; j<10; j++){
if(j == 0) dp[i][j] = dp[i-1][j+1];
else if(j == 9) dp[i][j] = dp[i-1][j-1];
else
dp[i][j] = dp[i-1][j-1] + dp[i-1][j+1];
if(i == n-1) sum += dp[i][j];
}
}
cout << sum % 1000000000;
}