Advertisement
Malinovsky239

Untitled

Nov 1st, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <cstdio>
  2. int a[50][50], n, m;
  3. int foo(int i, int j)
  4. {
  5.  
  6.   int q = 0, i1, j1;
  7.  
  8.   if (i > n)
  9.   {
  10.     i = 1;
  11.     j++;
  12.  
  13.     if (j == m + 1)      
  14.       return 1;
  15.   }
  16.  
  17.   if (!(a[i - 1][j] == 1 && a[i][j - 1] == 1 && a[i - 1][j - 1] == 1))
  18.   {
  19.     a[i][j] = 1;        
  20.     q = foo(i + 1, j);
  21.   }
  22.   if (!(a[i - 1][j] == 2 && a[i][j - 1] == 2 && a[i - 1][j - 1] == 2))
  23.   {
  24.     a[i][j] = 2;
  25.     q += foo(i + 1, j);
  26.   }                          
  27.   return q;
  28. }
  29. int main()
  30. {
  31.   freopen("nice.in", "r", stdin);
  32.   freopen("nice.out", "w", stdout);
  33.   scanf("%d%d", &n, &m);
  34.   printf("%d \n", foo(1, 1));
  35.   return 0;
  36. }
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement