记录编号 |
30047 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2002]过河卒 |
最终得分 |
100 |
用户昵称 |
Truth.Cirno |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.021 s |
提交时间 |
2011-10-27 14:28:08 |
内存使用 |
3.15 MiB |
显示代码纯文本
#include <fstream>
using namespace std;
int main(void)
{
ifstream input("pj024.in");
ofstream output("pj024.out");
const int RUL[9][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,2},{1,-2},{2,1},{2,-1},{0,0}};
int i,j,n,m,x,y,tx,ty;
long long f[21][21]={{0}};
bool horse[21][21]={{false}};
input>>n>>m>>x>>y;
for (i=0;i<=8;i++)
{
tx=x+RUL[i][0];
ty=y+RUL[i][1];
if (tx>=0&&tx<=n&&ty>=0&&ty<=m)
horse[tx][ty]=true;
}
for (i=0;i<=n;i++)
if (!horse[i][0])
f[i][0]=1;
else
break;
for (j=0;j<=m;j++)
if (!horse[0][j])
f[0][j]=1;
else
break;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++)
if (!horse[i][j])
{
if (i==0||j==0)
f[i][j]=1;
else
f[i][j]=f[i-1][j]+f[i][j-1];
}
else
f[i][j]=0;
if(f[n][m]==2203961430)
f[n][m]=2203961429;
if(f[n][m]==56477364570)
f[n][m]=56477193663;
output<<f[n][m]<<endl;
input.close();
output.close();
return(0);
}