fork(1) download
  1. #include <cstdio>
  2. #include <algorithm>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. #define N 3000
  8.  
  9. int n, h, m;
  10. long long f[61][90][N];
  11.  
  12. int main ( void ) {
  13. int TA;
  14.  
  15. scanf("%d", &TA);
  16.  
  17. memset(f, 0, sizeof f);
  18.  
  19. for(int cur = 1; cur <= 80; cur++)
  20. for(int rem = 0; rem <= 2500; rem++)
  21. f[0][cur][rem] = 1;
  22.  
  23. for(int lvl = 1; lvl <= 60; lvl++)
  24. for(int cur = 1; cur <= 80; cur++)
  25. for(int rem_cubes = 0; rem_cubes < 2500; rem_cubes++) {
  26. long long &ret = f[lvl][cur][rem_cubes];
  27.  
  28. int cand[] = {cur - 1, cur + 1};
  29.  
  30. for(int i = 0; i < 2; i++) {
  31. int last = cand[i];
  32.  
  33. if(last > rem_cubes || last <= 0) continue;
  34.  
  35. ret += f[lvl - 1][last][rem_cubes - last];
  36. }
  37. }
  38.  
  39.  
  40. while( TA-- ) {
  41. scanf("%d %d %d", &n, &h, &m);
  42. if( n > 2500 ) n = 2499;
  43. printf("%lld\n", f[h - 1][m][n - m]);
  44. }
  45. }
  46.  
Runtime error #stdin #stdout 0.27s 131776KB
stdin
Standard input is empty
stdout
Standard output is empty