Advertisement
AlexG2230954

Untitled

Feb 18th, 2022
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main() {
  6. int n, m;
  7. scanf("%d %d", &n, &m);
  8.  
  9. int* nums = malloc(sizeof(int) * (n + 1));
  10. nums[0] = 1;
  11. nums[1] = 1;
  12.  
  13. for(int k = 2; k <= n; k++) {
  14. nums[k] = 0;
  15.  
  16. for(int j = 0; j < k; j++)
  17. nums[k] += (nums[j] * nums[k - 1 - j]) % m;
  18. }
  19.  
  20. printf("%d", nums[n]);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement