-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.cpp
More file actions
53 lines (41 loc) · 953 Bytes
/
test2.cpp
File metadata and controls
53 lines (41 loc) · 953 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN = 100;
int n;
int dp[MAXN][MAXN][4] = {06};
int main(){
scanf("%d", &n);
dp[1][1][1] = 1;
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
if(i == 1 && j == 1) continue;
dp[i][j][1] = dp[i-1][j-1][1] + dp[i-1][j-1][2] + dp[i-1][j-1][3];
dp[i][j][2] = dp[i-1][j][1] + dp[i-1][j][2];
dp[i][j][3] = dp[i][j-1][1] + dp[i][j-1][3];
}
}
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
cout << dp[i][j][1] << " ";
}
cout << endl;
}
cout << endl;
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
cout << dp[i][j][2] << " ";
}
cout << endl;
}
cout << endl;
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
cout << dp[i][j][3] << " ";
}
cout << endl;
}
cout << endl;
cout << dp[n][n][1] + dp[n][n][2] + dp[n][n][3];
return 0;
}