当前位置:网站首页>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;
}
边栏推荐
- How to improve development quality
- 李迟2022年6月工作生活总结
- 2022 ByteDance daily practice experience (Tiktok)
- Principle and application of ThreadLocal
- Basic tutorial of scala -- 16 -- generics
- How is the entered query SQL statement executed?
- Grain Mall (I)
- 6.26CF模拟赛B:数组缩减题解
- [cloud native] what is the "grid" of service grid?
- Thawte通配符SSL证书提供的类型有哪些
猜你喜欢
力扣刷题日记/day3/2022.6.25
.NET ORM框架HiSql实战-第二章-使用Hisql实现菜单管理(增删改查)
[HCIA continuous update] WAN technology
Journal des problèmes de brosse à boutons de force / day6 / 6.28
Scala基础教程--17--集合
My colleagues quietly told me that flying Book notification can still play like this
基于unity的愤怒的小鸟设计
[2022 Jiangxi graduate mathematical modeling] curling movement idea analysis and code implementation
输入的查询SQL语句,是如何执行的?
uni-app与uviewUI实现仿小米商城app(附源码)
随机推荐
力扣刷题日记/day1/2022.6.23
基于unity的愤怒的小鸟设计
Esp32-c3 introductory tutorial questions ⑫ - undefined reference to ROM_ temp_ to_ power, in function phy_ get_ romfunc_ addr
Scala basic tutorial -- 15 -- recursion
Nature microbiology | viral genomes in six deep-sea sediments that can infect Archaea asgardii
File processing examples of fopen, FREAD, fwrite, fseek
2022 national CMMI certification subsidy policy | Changxu consulting
Neglected problem: test environment configuration management
Wireshark packet capturing TLS protocol bar displays version inconsistency
能源行业的数字化“新”运维
SIGMOD’22 HiEngine论文解读
Li Kou brush question diary /day5/2022.6.27
Scala基础教程--15--递归
Uni app and uviewui realize the imitation of Xiaomi mall app (with source code)
Behind the ultra clear image quality of NBA Live Broadcast: an in-depth interpretation of Alibaba cloud video cloud "narrowband HD 2.0" technology
Scala基础教程--16--泛型
力扣刷题日记/day2/2022.6.24
激进技术派 vs 项目保守派的微服务架构之争
学习路之PHP--phpstudy创建项目时“hosts文件不存在或被阻止打开”
NBA赛事直播超清画质背后:阿里云视频云「窄带高清2.0」技术深度解读