社区讨论
大家都是WAon#4,而我ACon#4,WAon其他点
P1002[NOIP 2002 普及组] 过河卒参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mhjs3cc5
- 此快照首次捕获于
- 2025/11/04 07:35 4 个月前
- 此快照最后确认于
- 2025/11/04 07:35 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
const short dx[]={1,1,-1,-1,2,2,-2,-2};
const short dy[]={2,-2,2,-2,1,-1,1,-1};
const short d1[]={1,0};
const short d2[]={0,1};
typedef long long l;
l dp[22][22];
bool b[22][22];
int main()
{
memset(b,false,sizeof(b));
dp[1][1]=1;
unsigned short ax,ay,bx,by;
scanf("%hu%hu%hu%hu",&ax,&ay,&bx,&by);
for(unsigned short i=0;i<8;i++)
{
if(bx+dx[i]<=ax&&by+dx[i]<=ay&&bx+dx[i]>=1&&by+dy[i]>=1) b[bx+dx[i]][by+dy[i]]=true;
}
b[bx][by]=true;
for(unsigned short i=1;i<=ax;i++)
{
for(unsigned short j=1;j<=ay;j++)
{
if(!b[i][j])
{
if(i>1) dp[i][j]+=dp[i-1][j];
if(j>1) dp[i][j]+=dp[i][j-1];
}
}
}
printf("%lld\n",dp[ax][ay]);
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...