-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1002dp.cpp
68 lines (63 loc) · 1.23 KB
/
1002dp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<queue>
#include<vector>
#define IL inline
#define re register
#define LL long long
#define ULL unsigned long long
#define re register
using namespace std;
template<class T>inline void read(T&x)
{
char ch=getchar();
while(!isdigit(ch))ch=getchar();
x=ch-'0';ch=getchar();
while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
}
inline int read()
{
int x=0;
char ch=getchar();
while(!isdigit(ch))ch=getchar();
x=ch-'0';ch=getchar();
while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
return x;
}
int G[55];
template<class T>inline void write(T x)
{
int g=0;
do{G[++g]=x%10;x/=10;}while(x);
for(int i=g;i>=1;--i)putchar('0'+G[i]);putchar('\n');
}
int n,m;
int mn,mm;
LL map[100][100];
bool inside(int a,int b)
{
return (a>=0&&b>=0&&a<=n&&b<=m);
}
LL calc(int i,int j)
{
if(!inside(i,j)) return 0;
if(i==mn&&j==mm) return 0;
if(abs(i-mn)+abs(j-mm)==3&&abs(i-mn)*abs(j-mm)==2) return 0;
return map[i][j];
}
int main()
{
cin>>n>>m>>mn>>mm;
for(int i=0;i<=n;i++)
for(int j=0;j<=m;j++)
{
if(i==0&&j==0) map[i][j]=1;
else map[i][j]=calc(i-1,j)+calc(i,j-1);
}
cout<<map[n][m];
return 0;
}