fork(2) download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. int** N = malloc(9 * sizeof(int*));
  7. for (int i = 1; i <= 8; i++)
  8. {
  9. int length = i * 9 + 1;
  10. N[i] = malloc(length * sizeof(int));
  11.  
  12. if (i == 1)
  13. {
  14. for (int j = 0; j < length; j++)
  15. N[i][j] = 1;
  16. }
  17. else
  18. {
  19. unsigned long long runningsum = 0;
  20. int k = 0;
  21. for ( ; k <= length / 2; k++)
  22. {
  23. runningsum += N[i-1][k];
  24. if (k >= 10)
  25. runningsum -= N[i-1][k-10];
  26. N[i][k] = runningsum;
  27. }
  28. for ( ; k < length; k++)
  29. {
  30. N[i][k] = N[i][length - 1 - k];
  31. }
  32. }
  33. }
  34.  
  35. for (int i = 1; i <= 8; i++)
  36. {
  37. for (int j = 0; j < i * 9 + 1; j++)
  38. {
  39. printf("%d ", N[i][j]);
  40. }
  41. printf("\n");
  42. }
  43.  
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0s 1920KB
stdin
Standard input is empty
stdout
1 1 1 1 1 1 1 1 1 1 
1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 
1 3 6 10 15 21 28 36 45 55 63 69 73 75 75 73 69 63 55 45 36 28 21 15 10 6 3 1 
1 4 10 20 35 56 84 120 165 220 282 348 415 480 540 592 633 660 670 660 633 592 540 480 415 348 282 220 165 120 84 56 35 20 10 4 1 
1 5 15 35 70 126 210 330 495 715 996 1340 1745 2205 2710 3246 3795 4335 4840 5280 5631 5875 6000 6000 5875 5631 5280 4840 4335 3795 3246 2710 2205 1745 1340 996 715 495 330 210 126 70 35 15 5 1 
1 6 21 56 126 252 462 792 1287 2002 2997 4332 6062 8232 10872 13992 17577 21582 25927 30492 35127 39662 43917 47712 50877 53262 54747 55252 54747 53262 50877 47712 43917 39662 35127 30492 25927 21582 17577 13992 10872 8232 6062 4332 2997 2002 1287 792 462 252 126 56 21 6 1 
1 7 28 84 210 462 924 1716 3003 5005 8001 12327 18368 26544 37290 51030 68145 88935 113575 142065 174195 209525 247380 286860 326865 366135 403305 436975 465795 488565 504315 512365 512365 504315 488565 465795 436975 403305 366135 326865 286860 247380 209525 174195 142065 113575 88935 68145 51030 37290 26544 18368 12327 8001 5005 3003 1716 924 462 210 84 28 7 1 
1 8 36 120 330 792 1716 3432 6435 11440 19440 31760 50100 76560 113640 164208 231429 318648 429220 566280 732474 929672 1158684 1419000 1708575 2023680 2358840 2706880 3059100 3405600 3735720 4038560 4303545 4521000 4682700 4782360 4816030 4782360 4682700 4521000 4303545 4038560 3735720 3405600 3059100 2706880 2358840 2023680 1708575 1419000 1158684 929672 732474 566280 429220 318648 231429 164208 113640 76560 50100 31760 19440 11440 6435 3432 1716 792 330 120 36 8 1