Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <stdlib.h>
- #include <stack>
- #include <queue>
- #include <set>
- #include <map>
- #include <string>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- int p, n, k;
- long long d[110][110][2];
- int main() {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- d[1][0][0] = d[1][0][1] = 1;
- for (int i = 2; i < 110; i++) {
- for (int j = 0; j < i; j++) {
- d[i][j][0] = d[i - 1][j][0] + d[i - 1][j][1];
- d[i][j][1] = d[i - 1][j][0];
- if (j)
- d[i][j][1] += d[i - 1][j - 1][1];
- }
- }
- scanf("%d", &p);
- for (int tst = 1; tst <= p; tst++) {
- scanf("%*d%d%d", &n, &k);
- printf("%d %lld\n", tst, d[n][k][0] + d[n][k][1]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement