60分,3和4错的,看看

P1002 [NOIP2002 普及组] 过河卒


by lytqwq @ 2018-12-08 18:38:11


#include<bits/stdc++.h> using namespace std; long long int a[1001][1001]; int main() { long long int n,i,s=1,m,x,y; cin>>n>>m>>x>>y; n++; m++; x++; y++; a[0][1] = 1; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { if ((abs(i-x)+abs(j-y)==3)&&(i!=x&&j!=y)||(i==x&&j==y)); else a[i][j]=a[i-1][j]+a[i][j-1]; } } cout<<a[n][m]<<endl; return 0; }
by Created_immortality @ 2018-12-08 19:31:16


#include<bits/stdc++.h> using namespace std; long long int a[1001][1001]; int main() { long long int n,i,s=1,m,x,y; cin>>n>>m>>x>>y; n++; m++; x++; y++; a[0][1] = 1; for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) { if ((abs(i-x)+abs(j-y)==3)&&(i!=x&&j!=y)||(i==x&&j==y)); else a[i][j]=a[i-1][j]+a[i][j-1]; } } cout<<a[n][m]<<endl; return 0; }
by Created_immortality @ 2018-12-08 19:32:07


var i,j,x,y,x1,y1,n,m:longint; a:array[-1..22,-1..22] of int64; b:array[-2..22,-2..22] of boolean; begin read(n,m,x,y); b[x,y]:=true; b[x+1,y-2]:=true; b[x+2,y-1]:=true; b[x-1,y-2]:=true; b[x-2,y-1]:=true; b[x+2,y+1]:=true; b[x+1,y+2]:=true; b[x-2,y+1]:=true; b[x-1,y+2]:=true; a[0,0]:=1; for i:=1 to n do if b[i,0] then break else a[i,0]:=1; for j:=1 to m do if b[0,j] then break else a[0,j]:=1; for i:=1 to n do for j:=1 to m do if not b[i,j] then a[i,j]:=a[i-1,j]+a[i,j-1]; write(a[n,m]); end. pascal
by 末将于禁 @ 2018-12-08 19:32:51


|