Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long gformas(int, int, int, int);
  4. int formas[101][101][11][11];
  5. int n1=0,n2=0,k1=0,k2=0,k3=0,k4=0;
  6. int m=100000000;
  7. int main(){
  8. ios::sync_with_stdio(0);
  9. cin.tie(0);
  10. for(int i=0;i<101;i++){
  11. for(int j=0;j<101;j++){
  12. for(int k=0;k<11;k++){
  13. for(int l=0;l<11;l++){
  14. formas[i][j][k][l]=-2;
  15. }
  16. }
  17. }
  18. }
  19. cout>>formas[100][100][10][10];
  20. cin>>n1>>n2>>k1>>k2;
  21. cout<<gformas(n1,n2,k1,k2)<<endl;
  22. return 0;
  23. }
  24. long long gformas(int n1,int n2,int k3,int k4){
  25. if(k3<0||k4<0||n1<0||n2<0){return 0;}
  26. if (n1==0&&n2==0){return 1;}
  27. if (formas[n1-1][n2][k3-1][k2]==-2){
  28. formas[n1-1][n2][k3-1][k2]=(gformas(n1-1,n2,k3-1,k2))%m;
  29. }
  30. if (formas[n1][n2-1][k1][k4-1]==-2){
  31. formas[n1][n2-1][k1][k4-1]=(gformas(n1,n2-1,k1,k4-1))%m;
  32. }
  33. return formas[n1][n2][k3][k4]=(formas[n1-1][n2][k3-1][k2]+formas[n1][n2-1][k1][k4-1])%m;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement