Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long gformas(int, int, int, int);
- int formas[101][101][11][11];
- int n1=0,n2=0,k1=0,k2=0,k3=0,k4=0;
- int m=100000000;
- int main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- for(int i=0;i<101;i++){
- for(int j=0;j<101;j++){
- for(int k=0;k<11;k++){
- for(int l=0;l<11;l++){
- formas[i][j][k][l]=-2;
- }
- }
- }
- }
- cout>>formas[100][100][10][10];
- cin>>n1>>n2>>k1>>k2;
- cout<<gformas(n1,n2,k1,k2)<<endl;
- return 0;
- }
- long long gformas(int n1,int n2,int k3,int k4){
- if(k3<0||k4<0||n1<0||n2<0){return 0;}
- if (n1==0&&n2==0){return 1;}
- if (formas[n1-1][n2][k3-1][k2]==-2){
- formas[n1-1][n2][k3-1][k2]=(gformas(n1-1,n2,k3-1,k2))%m;
- }
- if (formas[n1][n2-1][k1][k4-1]==-2){
- formas[n1][n2-1][k1][k4-1]=(gformas(n1,n2-1,k1,k4-1))%m;
- }
- return formas[n1][n2][k3][k4]=(formas[n1-1][n2][k3-1][k2]+formas[n1][n2-1][k1][k4-1])%m;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement