Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int n, m;
- scanf("%d %d", &n, &m);
- int* nums = malloc(sizeof(int) * (n + 1));
- nums[0] = 1;
- nums[1] = 1;
- for(int k = 2; k <= n; k++) {
- nums[k] = 0;
- for(int j = 0; j < k; j++)
- nums[k] += (nums[j] * nums[k - 1 - j]) % m;
- }
- printf("%d", nums[n]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement