4 条题解
-
1
#include<bits/stdc++.h> using namespace std; #define LL long long //过河卒 。 const int N = 1e5 + 10; const int M = 5e4 + 10; const int INF = 0x3f3f3f3f; const short dir[8][2] = { { 1 , 2 } , { 1 , -2 } , { 2 , 1 } , { 2 , -1 } , { -1 , 2 } , { -1 , -2 } , { -2 , 1 } , { -2 , -1 } }; bool d[30][30]; int dp[30][30] , n , m , x , y; //声明变量与常量完成。 signed main() { cin >> n >> m >> x >> y; //输入数据。 d[x][y] = 1; for ( int i = 0 ; i < 8 ; i++ ) { int tx = x + dir[i][0] , ty = y + dir[i][1]; if ( tx >= 0 && tx <= n && ty >= 0 && ty <= m ) { d[tx][ty] = 1; } } dp[0][0] = 1; //cout << dp[0][0]; for ( int i = 0 ; i <= n ; i++ ) { for ( int j = 0 ; j <= m ; j++ ) { if ( !d[i][j] ) { if ( i ) { dp[i][j] += dp[ i - 1 ][j]; } if ( j ) { dp[i][j] += dp[i][ j - 1 ]; } } } } cout << dp[n][m] << endl; //cout << M << " " << N; return 0; } //菜鸟驿站 //老六专属
信息
- ID
- 659
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 2
- 标签
- 递交数
- 91
- 已通过
- 54
- 上传者