当前位置:网站首页>repeat_P1002 [NOIP2002 普及组] 过河卒_dp
repeat_P1002 [NOIP2002 普及组] 过河卒_dp
2022-07-04 17:14:00 【这题AC再睡.】
repeat_P1002 [NOIP2002 普及组] 过河卒_dp
//
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int dx[]={ 0,1,1,-1,-1,2,2,-2,-2 };
const int dy[]={ 0,2,-2,2,-2,1,-1,1,-1 };
const int N=22;
bool used[N][N];
LL dp[N][N];
int n,m,x,y;
void init()
{
memset( used,0,sizeof( used ) );
memset( dp,0,sizeof( dp ) );
int i,j,tx,ty;
for( i=0;i<9;i++ )
{
tx=x+dx[i]; ty=y+dy[i];
if( tx>=0 && tx<=n && ty>=0 && ty<=m ) used[tx][ty]=1;
}
for( i=0;i<=n;i++ ) // =
{
if( used[i][0] ) break; //
dp[i][0]=1;
}
for( j=0;j<=m;j++ ) // =
{
if( used[0][j] ) break; //
dp[0][j]=1;
}
}
int main()
{
int i,j;
while( cin>>n>>m>>x>>y )
{
init();
for( i=1;i<=n;i++ )
for( j=1;j<=m;j++ )
if( used[i][j]==0 )
dp[i][j]=dp[i-1][j]+dp[i][j-1];
cout<<dp[n][m]<<endl;
}
return 0;
}
边栏推荐
- 【系统盘转回U盘】记录系统盘转回U盘的操作
- 【2022年江西省研究生数学建模】冰壶运动 思路分析及代码实现
- Scala基础教程--18--集合(二)
- Scala basic tutorial -- 14 -- implicit conversion
- 【机器学习的数学基础】(一)线性代数(Linear Algebra)(上+)
- [go ~ 0 to 1] read, write and create files on the sixth day
- [cloud native] what is the "grid" of service grid?
- Scala basic tutorial -- 18 -- set (2)
- TCP waves twice, have you seen it? What about four handshakes?
- Scala基础教程--16--泛型
猜你喜欢
随机推荐
[211] go handles the detailed documents of Excel library
大厂面试总结大全二
Halcon template matching
Detailed explanation of the maturity classification of ITSS operation and maintenance capability | one article clarifies the ITSS certificate
Learning path PHP -- phpstudy "hosts file does not exist or is blocked from opening" when creating the project
Reptile elementary learning
[system disk back to U disk] record the operation of system disk back to U disk
[go language question brushing chapter] go conclusion chapter | introduction to functions, structures, interfaces, and errors
Scala basic tutorial -- 18 -- set (2)
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
SIGMOD’22 HiEngine论文解读
Scala basic tutorial -- 15 -- recursion
ThreadLocal原理与使用
Grain Mall (I)
【云端心声 建议征集】云商店焕新升级:提有效建议,赢海量码豆、华为AI音箱2!
Interview summary of large factory Daquan II
Microservice architecture debate between radical technologists vs Project conservatives
Nature microbiology | viral genomes in six deep-sea sediments that can infect Archaea asgardii
同事悄悄告诉我,飞书通知还能这样玩
Principle and application of ThreadLocal