-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaesorsLegion.java
More file actions
73 lines (64 loc) · 1.92 KB
/
caesorsLegion.java
File metadata and controls
73 lines (64 loc) · 1.92 KB
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
68
69
70
71
72
73
import java.awt.Point;
import java.io.*;
import java.util.*;
public class caesorsLegion {
static long[][][][] dp;
static int n1,n2,k1,k2,mod=(int)1e8;
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
n1=sc.nextInt();n2=sc.nextInt();k1=sc.nextInt();k2=sc.nextInt();
dp=new long[101][101][11][11];
for(long[][][] a:dp)for(long[][] b:a)for(long[] c:b)Arrays.fill(c,-1);
long ans=dp(n1,n2,0,0)%mod;
System.out.println(ans);
}
public static long dp(int a,int b,int count1,int count2){
if(a==0 && b==0)return 1;
if(dp[a][b][count1][count2]!=-1)return dp[a][b][count1][count2];
long count=0;
if(a>0 && count1!=k1){
if(count2==k2) count=(count+dp(a-1,b,1,0)%mod)%mod;
else count=(count+dp(a-1,b,count1+1,0)%mod)%mod;
}
if(b>0 && count2!=k2){
if(count1==k1)count=(count+dp(a,b-1,0,1)%mod)%mod;
else count=(count+dp(a,b-1,0,count2+1)%mod)%mod;
}
return dp[a][b][count1][count2]=count;
}
}
class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}