SHOW:
|
|
- or go back to the newest paste.
1 | #include <iostream> | |
2 | ||
3 | using namespace std; | |
4 | int main(){ | |
5 | int n,m; | |
6 | cin >> n >> m; | |
7 | ||
8 | int board[n][m]; | |
9 | ||
10 | for(int i=0; i < n; i++){ | |
11 | for(int j=0; j<m; j++){ | |
12 | board[i][j] = 0; | |
13 | } | |
14 | } | |
15 | ||
16 | board[0][0] = 1; | |
17 | for(int i = 0; i < n; i++){ | |
18 | for(int j = 0; j < m; j++){ | |
19 | int temp = 0; | |
20 | if(i >= 1 && j >= 2){ | |
21 | temp += board[i-1][j-2]; | |
22 | } | |
23 | ||
24 | if(i >= 2 && j >= 1){ | |
25 | temp += board[i-2][j-1]; | |
26 | } | |
27 | ||
28 | board[i][j] += temp; | |
29 | } | |
30 | } | |
31 | ||
32 | ||
33 | cout << board[n-1][m-1] << endl; | |
34 | ||
35 | ||
36 | } |