求数据范围

P1002 [NOIP2002 普及组] 过河卒

结果long long,棋盘≤30\*30
by Victory_Defeat @ 2017-12-07 20:50:10


谢谢 还有个问题,我的程序会re,求大佬们解释 ```cpp #include<iostream> #include<cmath> #include<vector> #include<map> #include<algorithm> #include<string> #include<cstdlib> #include<queue> #include<climits> #include<set> #include<cstring> using namespace std; struct position { int xx; int yy; }; position final,horse; bool control[100][100]; void in(); long long find(int x,int y); int main() { in(); cout << find(final.xx,final.yy); return 0; } void in() { cin >> final.xx >> final.yy >> horse.xx >> horse.yy; memset(control,0,sizeof(control)); control[horse.xx][horse.yy] = 1; control[horse.xx+2][horse.yy+1] = 1; control[horse.xx+2][horse.yy-1] = 1; control[horse.xx+1][horse.yy+2] = 1; control[horse.xx+1][horse.yy-2] = 1; control[horse.xx-1][horse.yy+2] = 1; control[horse.xx-1][horse.yy-2] = 1; control[horse.xx-2][horse.yy+1] = 1; control[horse.xx-2][horse.yy-1] = 1; } long long find(int x,int y) { if(control[x][y]) { return 0; } if(x < 0 || y < 0) { return 0; } if(x == 0 && y == 0) { return 1; } long long ans = find(x,y-1) + find(x-1,y); cout << ans << endl; return ans; } ```
by HygoK67 @ 2017-12-07 20:52:41


我试出了2个wa和3个tle! PS:本蒟蒻AC代码: ```cpp #include<cstdio> long long x,y,n,m,a[30][30],f[30][30]; void z(long long x,long long y) { f[x][y]=1; f[x-1][y-2]=1; f[x-2][y-1]=1; f[x-2][y+1]=1; f[x-1][y+2]=1; f[x+1][y-2]=1; f[x+2][y-1]=1; f[x+2][y+1]=1; f[x+1][y+2]=1; } void work() { a[1][0]=1; for(int i=1;i<=n+1;i++) for(int j=1;j<=m+1;j++) if(f[i-1][j-1]) a[i][j]=0; else a[i][j]=a[i-1][j]+a[i][j-1]; printf("%lld",a[n+1][m+1]); } int main() { scanf("%lld%lld%lld%lld",&n,&m,&x,&y); z(x,y); work(); } ```
by Victory_Defeat @ 2017-12-07 21:17:27


一脸懵逼的我用了高精度 然后 屏幕上 火辣辣一片
by retired_treasure @ 2018-01-01 21:03:05


|