294 条题解
-
0diyidecainiao LV 6 @ 2016-07-25 18:21:21
#include <stdio.h> #include <stdlib.h> int cx,cy,m,n; int map[16][16]; int f(int a,int b) { if(map[a][b]==1) return 0; if(a==0&&b==0) return 1; if(a==0) return f(a,b-1); if(b==0) return f(a-1,b); return f(a-1,b)+f(a,b-1); } int main() { int paths; const int x[10]={ 2, 1,-2,-1, 2, 1,-2,-1, 2,-2}; const int y[10]={ 1, 2,-1,-2,-1,-2, 1, 2, 2,-2}; scanf("%d %d %d %d",&n,&m,&cx,&cy); { int i; map[cx][cy]=1; for(i=0;i<10;i++) if(cx+x[i]>=0&&cx+x[i]<=n&&cy+y[i]>=0&&cy+y[i]<=m) map[cx+x[i]][cy+y[i]]=1; } paths=f(n,m); printf("%d",paths); return 0; }
-
02016-07-13 22:13:50@
记录信息 评测状态 Accepted 题目 P1121 马拦过河卒 递交时间 2016-05-17 21:50:30 代码语言 C++ 评测机 ShadowShore 消耗时间 0 ms 消耗内存 656 KiB 评测时间 2016-05-17 21:50:32 评测结果 编译成功 测试数据 #0: Accepted, time = 0 ms, mem = 652 KiB, score = 10 测试数据 #1: Accepted, time = 0 ms, mem = 656 KiB, score = 10 测试数据 #2: Accepted, time = 0 ms, mem = 652 KiB, score = 10 测试数据 #3: Accepted, time = 0 ms, mem = 652 KiB, score = 10 测试数据 #4: Accepted, time = 0 ms, mem = 656 KiB, score = 10 测试数据 #5: Accepted, time = 0 ms, mem = 656 KiB, score = 10 测试数据 #6: Accepted, time = 0 ms, mem = 656 KiB, score = 10 测试数据 #7: Accepted, time = 0 ms, mem = 652 KiB, score = 10 测试数据 #8: Accepted, time = 0 ms, mem = 656 KiB, score = 10 测试数据 #9: Accepted, time = 0 ms, mem = 656 KiB, score = 10 Accepted, time = 0 ms, mem = 656 KiB, score = 100 代码 #include<cstdio> #include<cstring> using namespace std; int main() { long n,m,x,y; int l1[10]={0,0,1,-1,1,-1,-2,-2,2,2}; int l2[10]={0,0,-2,-2,2,2,-1,1,1,-1}; long long a[101][101],b[101][101]; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); scanf("%ld %ld %ld %ld",&n,&m,&x,&y); for(int i=1;i<=9;i++) if(y+l2[i]>=0 && x+l1[i]>=0) b[x+l1[i]][y+l2[i]]=1; a[0][0]=1; for(int i=1;i<=m;i++) if(b[0][i]==0) a[0][i]=a[0][i-1]; for(int i=1;i<=n;i++) if(b[i][0]==0) a[i][0]=a[i-1][0]; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(b[i][j]==0) a[i][j]=a[i-1][j]+a[i][j-1]; printf("%I64d",a[n][m]); return 0; }
-
02016-07-12 10:43:56@
#include<iostream>
using namespace std;
int main()
{
int x,y,s,t;
cin>>x>>y>>s>>t;
long long a[x+1][y+1],b[x+1][y+1];
for(int i=0;i<=x;i++)
for(int j=0;j<=y;j++)
{
a[i][j]=0;
b[i][j]=0;
}
a[0][0]=1;
b[s+1][t+2]=1;
b[s+1][t-2]=1;
b[s+2][t+1]=1;
b[s+2][t-1]=1;
b[s-1][t-2]=1;
b[s-1][t+2]=1;
b[s-2][t+1]=1;
b[s-2][t-1]=1;
b[s][t]=1;
for(int i=0;i<=x;i++)
for(int j=0;j<=y;j++)
{
if(i>=1&&b[i][j]==0)
a[i][j]+=a[i-1][j];
if(j>=1&&b[i][j]==0)
a[i][j]+=a[i][j-1];
}
cout<<a[x][y];
} -
02016-04-03 11:07:14@
#include<iostream>
#include<cstring>
using namespace std;
void chu();
void chick(int n,int m);
void machick(int n, int m);
int getabc();
struct Nzb
{
int x;
int y;
};
Nzb ma,zhong;
int a[20][20];
bool malan[20][20];
int main()
{
cin >> zhong.x >> zhong.y >> ma.x >> ma.y;
memset(malan, true, sizeof(malan));
machick(ma.x, ma.y);
chu();
cout << getabc()<<endl;
return 0;
}
void chu()
{
int Temp1,Temp2;
memset(a, 0, sizeof(a));
for (Temp1 = 0; Temp1 <= zhong.x; Temp1++)
{
if (!malan[Temp1][0])
{
a[Temp1][0] = 0;
break;
}
else
a[Temp1][0] = 1;
}
for (Temp2 = 0; Temp2 <= zhong.y; Temp2++)
{
if (!malan[0][Temp2])
{
a[0][Temp2] = 0;
break;
}
else
a[0][Temp2] = 1;
}
}
void machick(int n, int m)
{
if ((n + 1 >= 0) && (n + 1 <= 15) && (m + 2 >= 0)&&(m + 2 <= 15))
malan[n + 1][m + 2] = false;
if ((n - 1 >= 0) && (n - 1 <= 15) && (m + 2 >= 0) && (m + 2 <= 15))
malan[n - 1][m + 2] = false;
if ((n + 1 >= 0) && (n + 1 <= 15) && (m - 2 >= 0) && (m - 2 <= 15))
malan[n + 1][m - 2] = false;
if ((n - 1 >= 0) && (n - 1 <= 15) && (m - 2 >= 0) && (m - 2 <= 15))
malan[n - 1][m - 2] = false;
if ((n + 2 >= 0) && (n + 2 <= 15) && (m + 1 >= 0) && (m + 1 <= 15))
malan[n + 2][m + 1] = false;
if ((n - 2 >= 0) && (n - 2 <= 15) && (m + 1 >= 0) && (m + 1 <= 15))
malan[n - 2][m + 1] = false;
if ((n + 2 >= 0) && (n + 2 <= 15) && (m - 1 >= 0) && (m - 1 <= 15))
malan[n + 2][m - 1] = false;
if ((n - 2 >= 0) && (n - 2 <= 15) && (m - 1 >= 0) && (m -1 <= 15))
malan[n - 2][m - 1] = false;
malan[n][m] = false;
}
int getabc()
{
int Temp1, Temp2;
for (Temp1 = 1; Temp1 <= zhong.x; Temp1++)
{
for (Temp2 = 1; Temp2 <= zhong.y; Temp2++)
{
if (malan[Temp1][Temp2])
{
if (malan[Temp1 - 1][Temp2])
a[Temp1][Temp2] += a[Temp1 - 1][Temp2];
if (malan[Temp1][Temp2 - 1])
a[Temp1][Temp2] += a[Temp1][Temp2 - 1];
}
}
}
return a[zhong.x][zhong.y];
} -
02015-11-05 22:24:04@
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;int martix[10000][10000];
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
memset(martix,0,sizeof(martix));
martix[c][d]=-1;
for(int i=0;i<=a;i++)
martix[i][0]=1;
for(int i=0;i<=b;i++)
martix[0][i]=1;
if(c+2<=10000){
if(d+1>=0 && d+1<10000) martix[c+2][d+1]=-1;
if(d-1>=0 && d-1<10000) martix[c+2][d-1]=-1;
}
if(c-2<=10000 && c>=2){
if(d+1>=0 && d+1<10000) martix[c-2][d+1]=-1;
if(d-1>=0 && d-1<10000) martix[c-2][d-1]=-1;
}
if(d+2<=10000){
if(c+1>=0 && c+1<10000) martix[c+1][d+2]=-1;
if(c-1>=0 && c-1<10000) martix[c-1][d+2]=-1;
}
if(d-2<=10000 && d>=2){
if(c+1>=0 && c+1<10000) martix[c+1][d-2]=-1;
if(c-1>=0 && c-1<10000) martix[c-1][d-2]=-1;
}
if(c==0 || d==0){ martix[c][d]=-1; }
for(int i=0;i<=a;i++){
if(martix[i][0]==-1){
for(int j=i+1;j<=a;j++){
martix[j][0]=0;
}
break;
}
}
for(int i=0;i<=b;i++){
if(martix[0][i]==-1){
for(int j=i+1;j<=b;j++){
martix[0][j]=0;
}
break;
}
}
for(int i=1;i<=a;i++){
for(int j=1;j<=b;j++){
if(martix[i][j]==-1) continue;
else if(martix[i-1][j]!=-1 && martix[i][j-1]!=-1) martix[i][j]=martix[i-1][j]+martix[i][j-1];
else if(martix[i-1][j]==-1 && martix[i][j-1]!=-1) martix[i][j]=martix[i][j-1];
else if(martix[i-1][j]!=-1 && martix[i][j-1]==-1) martix[i][j]=martix[i-1][j];
else if(martix[i-1][j]==-1 && martix[i][j-1]==-1) continue;
}
}
cout<<(martix[a][b]==-1?0:martix[a][b]);
return 0;
} -
02015-10-31 15:46:57@
var a,f:array[-10..100,-10..100] of longint;
i,j,k,l,n,m,x,y:longint;
begin
read(n,m,x,y);
a[x,y]:=1;
a[x-1,y-2]:=1;
a[x-1,y+2]:=1;
a[x-2,y-1]:=1;
a[x-2,y+1]:=1;
a[x+1,y+2]:=1;
a[x+1,y-2]:=1;
a[x+2,y-1]:=1;
a[x+2,y+1]:=1;
f[0,-1]:=1;
for i:=0 to n do
for j:=0 to m do
if a[i,j]<>1 then
f[i,j]:=f[i-1,j]+f[i,j-1];
writeln(f[n,m]);
end.
f[i,j]表示到(i,j)的方案数,然后知道只能由(i-1,j)和(i,j-1)到达,所以方案数也是由这两个点得到。然后。。没有然后了。 -
02015-10-05 09:29:02@
此题水炸天【暴力搜索本来只想骗分也能过】
var a:array[0..20,0..20]of boolean;i,j,x,y,m,n,ans:longint;procedure zhunbei;
begin
fillchar(a,sizeof(a),true);
a[x,y]:=false;
if x-2>=0 then begin {马的上方}
if y-1>=0 then a[x-2,y-1]:=false;
if y+1<=m then a[x-2,y+1]:=false;
end;
if x+2<=n then begin {马的下方}
if y-1>=0 then a[x+2,y-1]:=false;
if y+1<=m then a[x+2,y+1]:=false;
end;
if y-2>=0 then begin {马的左方}
if x-1>=0 then a[x-1,y-2]:=false;
if x+1<=n then a[x+1,y-2]:=false;
end;
if y+2<=m then begin {马的右方}
if x-1>=0 then a[x-1,y+2]:=false;
if x+1<=n then a[x+1,y+2]:=false;
end;
end;procedure dfs(i,j:longint);
begin
if not(a[i,j]) then exit;
if (i=n) and (j=m) then begin
inc(ans); exit; end;
if i<n then dfs(i+1,j);
if j<m then dfs(i,j+1);
end;begin
read(n,m,x,y);
zhunbei;
ans:=0;
dfs(0,0);
writeln(ans);
end. -
02015-09-20 16:45:22@
题解:http://www.cnblogs.com/xtx1999/p/4823720.html
有疑问请留言 共同进步 -
02015-09-20 11:33:31@
编译成功
测试数据 #0: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 276 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 276 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 276 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 276 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 272 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 276 KiB, score = 10
Accepted, time = 0 ms, mem = 276 KiB, score = 100
#include<iostream>
#include<cstdio>
using namespace std;
int x1,y1,x2,y2;
int f[16][16],a[16][16],ans;
int mx[8]={1,2,2,1,-1,-2,-2,-1};
int my[8]={2,1,-1,-2,-2,-1,1,2};
int main()
{
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
a[x2][y2]=1;
for(int i=0;i<=7;i++){
if(x2+mx[i]<=x1&&y2+my[i]<=y1)
a[x2+mx[i]][y2+my[i]]=1;
}
f[0][0]=1;
for(int i=0;i<=x1;i++)
for(int j=0;j<=y1;j++){
if(i>0&&!a[i-1][j])
f[i][j]+=f[i-1][j];
if(j>0&&!a[i][j-1])
f[i][j]+=f[i][j-1];
}
printf("%d",f[x1][y1]);
}
秒杀。。。。 -
02015-08-24 16:03:07@
记忆搜索DP
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = 300;
const int M = 10;
LL dp[N][N];
int a,b,c,d;
bool jd(int x,int y)
{
if(x == c && y == d)
return true;
if(x == (c - 1)&& (y == d + 2|| y == d - 2))
return true;
if(x == (c + 1)&& (y == d + 2|| y == d - 2))
return true;
if(y == (d + 1) && (x == c + 2 || x == c - 2))
return true;
if(y == (d - 1) && (x == c + 2 || x == c - 2))
return true;
return false;
}
LL DP(int x,int y)
{
if( x > a || y > b || jd(x,y))
return 0;
if(dp[x][y] != -1)
return dp[x][y];
return dp[x][y] = DP(x + 1,y) + DP(x,y+1);
}
int main()
{
while(~scanf("%d%d%d%d",&a,&b,&c,&d))
{
memset(dp,-1,sizeof(dp));
dp[a][b] = 1;
printf("%I64d\n",DP(0,0));
}
} -
02015-08-23 13:24:20@
#include <iostream>
//#include <fstream>
using namespace std;
bool g[30][30];
long f(int i,int j)
{
if(g[i][j])return 0;
if((!i)||(!j))return 1;
if(i&&j)return f(i-1,j)+f(i,j-1);
return 0;
}
int main()
{
//ifstream cin("p1121.in",ios::in);
//ofstream cout("p1121.out",ios::out);
int n,m,x,y;
cin>>n>>m>>x>>y;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
g[i][j]=false;
g[x][y]=true;
if((x-2>=0 )&&(x-2<=n )&&(y-1>=0 )&&(y-1<=m)) g[x-2][y-1] =true;
if((x-2>=0 )&&(x-2<=n )&&(y+1>=0)&&(y+1<=m))g[x-2][y+1] =true;
if((x-1>=0 )&&(x-1<=n )&&(y+2>=0)&&(y+2<=m))g[x-1][y+2] =true;
if((x-1>=0 )&&(x-1<=n )&&(y-2>=0 )&&(y-2<=m)) g[x-1][y-2] =true;
if((x+1>=0)&&(x+1<=n)&&(y+2>=0)&&(y+2<=m))g[x+1][y+2] =true;
if((x+1>=0)&&(x+1<=n)&&(y-2>=0 )&&(y-2<=m)) g[x+1][y-2] =true;
if((x+2>=0)&&(x+2<=n)&&(y+1>=0)&&(y+1<=m))g[x+2][y+1] =true;
if((x+2>=0)&&(x+2<=n)&&(y-1>=0 )&&(y-1<=m)) g[x+2][y-1] =true;
if((!m)||(!n)||(g[1][0]&&g[0][1]))cout<<0;
else cout<<f(n,m);
//cin.close();
//cout.close();
return 0;
} -
02015-08-17 17:31:53@
#include<cstdio>
#include<cstring>
using namespace std;
long long g[21][21],f[21][21];
int main()
{
//freopen("knight.in","r",stdin);
//freopen("knight.out","w",stdout);
int m,n,i,j,k,a,b;
scanf("%d%d%d%d",&m,&n,&a,&b);
memset(g,-1,sizeof(g));
g[a][b]=0;
if(a-2>=0&&b-1>=0) g[a-2][b-1]=0;
if(a-1>=0&&b-2>=0) g[a-1][b-2]=0;
if(a+1<=m&&b-2>=0) g[a+1][b-2]=0;
if(a+2<=m&&b-1>=0) g[a+2][b-1]=0;
if(a-2>=0&&b+1<=n) g[a-2][b+1]=0;
if(a-1>=0&&b+2<=n) g[a-1][b+2]=0;
if(a+1<=m&&b+2<=n) g[a+1][b+2]=0;
if(a+2<=m&&b+1<=n) g[a+2][b+1]=0;
memset(f,0,sizeof(f));
f[1][0]=1;
f[0][1]=1;
if(g[1][0]==0){
f[1][0]=0;
}
if(g[0][1]==0){
f[0][1]=0;
}
for(i=2;i<=m+n;i++)
{
j=0;
k=i;
while(j<=i&&k>=0)
{
if(j<=m&&k<=n&&g[j][k]!=0)
{
if(j-1>=0)
f[j][k]+=f[j-1][k];
if(k-1>=0)
f[j][k]+=f[j][k-1];
/*printf("f[%d][%d]=",j,k);
printf("%I64d\n",f[j][k]);*/
}
j++;
k--;
}
}
printf("%I64d\n",f[m][n]);
return 0;
} -
02015-08-17 10:35:14@
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;int f[25][25],i,j,n,m,x,y,x1,x2,l;
bool a[25][25];int dp(int x2,int y2)
{
if (x2==x && y2==y)
{
l++;
return 0;
}
if (x2<x && a[x2+1][y2]==true)
{dp(x2+1,y2);
}
if (y2<y && a[x2][y2+1]==true)
{dp(x2,y2+1);
}
if (y2>y && a[x2][y2-1]==true)
{dp(x2,y2-1);
}
}int main()
{
cin>>x>>y>>x1>>x2;
for (i=0;i<=15;i++)
for (j=0;j<=15;j++)
a[i][j]=true;
a[x1][x2]=false;
if (x2-1>=0) a[x1+2][x2-1]=false;
a[x1+2][x2+1]=false;
if (x2-1>=0 && x1-2>=0) a[x1-2][x2-1]=false;
if (x1-2>=0) a[x1-2][x2+1]=false;
a[x1+1][x2+2]=false;
if (x1-1>=0) a[x1-1][x2+2]=false;
if (x2-2>=0 && x1-1>=0) a[x1-1][x2-2]=false;
if (x2-2>=0) a[x1+1][x2-2]=false;
dp(0,0);
cout <<l;
} -
02015-08-17 09:24:20@
有什么问题就找那个用户名叫黎明前的光的大神
-
02015-08-16 16:49:17@
#include<iostream>
#include<cstring>
using namespace std;const int maxn=20;
int d[maxn][maxn],n,m,x,y,vis[maxn][maxn]={0};bool pd(int i,int j) {
if (i==x-2&&j==y-1) return 1;
if (i==x-2&&j==y+1) return 1;
if (i==x+2&&j==y-1) return 1;
if (i==x+2&&j==y+1) return 1;
if (i==x-1&&j==y-2) return 1;
if (i==x-1&&j==y+2) return 1;
if (i==x+1&&j==y-2) return 1;
if (i==x+1&&j==y+2) return 1;
if (i==x&&j==y) return 1;
return 0;
}int dp(int i,int j) {
if (i>n||j>m) return -1;
else if (pd(i,j)) return -1;
else if (i==n&&j==m) return d[i][j]=1;
else if (vis[i][j]) return d[i][j];
int &ans=d[i][j];
vis[i][j]=1;
if (dp(i+1,j)!=-1) {
if (ans==-1) ans=0;
ans+=d[i+1][j];
}
if (dp(i,j+1)!=-1) {
if (ans==-1) ans=0;
ans+=d[i][j+1];
}
// cout<<"d["<<i<<','<<j<<"]="<<d[i][j]<<endl;
return ans;
}int main() {
memset(d,-1,sizeof(d));
cin>>n>>m>>x>>y;
dp(0,0);
cout<<(d[0][0]==-1?0:d[0][0]);
return 0;
} -
02015-08-09 16:33:30@
#include <iostream>
#include <stdio.h>
#include <string.h>using namespace std;
int n , m;
int a , b;int f[15 + 5][15 + 5];
void mark( int a , int b )
{
if( a >= 0 && b >= 0 )
f[a][b] = 0;
return;
}int dp( int a , int b )
{
if( a < 0 || b < 0 )
return 0;
if( f[a][b] != -1 )
return f[a][b];
if( a == 0 && b == 0 )
return 1;
return f[a][b] = dp( a - 1 , b ) + dp( a , b - 1 );
}int main()
{
scanf( "%d %d" , &n , &m );
scanf( "%d %d" , &a , &b );
memset( f , -1 , sizeof( f ) );
mark( a - 2 , b - 1 );
mark( a - 2 , b + 1 );
mark( a + 2 , b - 1 );
mark( a + 2 , b + 1 );
mark( a - 1 , b - 2 );
mark( a - 1 , b + 2 );
mark( a + 1 , b - 2 );
mark( a + 1 , b + 2 );
mark( a , b );
cout << dp( n , m ) << endl;
return 0;
}
小时候一直没有做对的题 -
02015-06-29 11:16:54@
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int s=0,n,m;
int a[50][50];
void dfs(int x,int y){
if ((x==n)&&(y==m)) s++;
if ((x+1<=n)&&(a[x+1][y]==0)) {
a[x+1][y]=1;
dfs(x+1,y);
a[x+1][y]=0;
}
if ((y+1<=m)&&(a[x][y+1]==0)) {
a[x][y+1]=1;
dfs(x,y+1);
a[x][y+1]=0;
}
}
int main()
{
int x,y;
scanf("%d %d %d %d",&n,&m,&x,&y);
memset(a,0,sizeof(a));
a[x][y]=1;
a[x-2][y-1]=1;
a[x-1][y-2]=1;
a[x-2][y+1]=1;
a[x-1][y+2]=1;
a[x+2][y-1]=1;
a[x+1][y-2]=1;
a[x+2][y+1]=1;
a[x+1][y+2]=1;
dfs(0,0);
printf("%d",s);
return 0;
} -
02015-06-24 22:19:18@
C++ Code
#include <iostream>
using namespace std;int v[16][16];
int max(int x1,int x2)
{
return x1>x2?x1:x2;
}int hx,hy,x,y;
bool ava(int x1,int y1)
{
if
(
(x1==hx && y1==hy)
||
((x1+1==hx||x1-1==hx)&&(y1+2==hy||y1-2==hy))
||
((y1+1==hy||y1-1==hy)&&(x1+2==hx||x1-2==hx))
)
{
return false;
}
return true;
}
int main()
{
cin>>x>>y>>hx>>hy;
hx++;
hy++;
x++;
y++;if(ava(1,1))v[1][1]=1;
for(int i=2;i<=x;i++)
{
v[i][1]=v[i-1][1];
if(ava(i,1)==false)v[i][1]=0;
}
for(int i=2;i<=y;i++)
{
v[1][i]=v[1][i-1];
if(ava(1,i)==false)v[1][i]=0;
}
for(int xx=2;xx<=x;xx++)
{
for(int yy=2;yy<=y;yy++)
{
if(ava(xx,yy))
{
v[xx][yy]=v[xx-1][yy]+v[xx][yy-1];
}
else v[xx][yy]=0;
}
}cout<<v[x][y]<<endl;
return 0;
} -
02015-06-12 21:44:51@
非常水呀
-
02015-06-12 21:44:15@
program p1287;
var
a:array[-1..21,-1..21] of longint;
i,j,k,m,n,x,y:longint;
begin
readln(n,m,x,y);
a[x,y]:=-1;
a[x+1,y+2]:=-1;
a[x+1,y-2]:=-1;
a[x+2,y-1]:=-1;
a[x+2,y+1]:=-1;
a[x-1,y-2]:=-1;
a[x-1,y+2]:=-1;
a[x-2,y-1]:=-1;
a[x-2,y+1]:=-1;
a[0,0]:=1;
for i:=0 to n do
for j:=0 to m do
begin
if a[i,j]=0 then
begin
a[i,j]:=a[i-1,j]+a[i,j-1];
if a[i-1,j]=-1 then inc(a[i,j]);
if a[i,j-1]=-1 then inc(a[i,j]);
end;
end;
writeln(a[n,m]);
end.