Skip to content

Instantly share code, notes, and snippets.

@Baekjoon
Created September 27, 2015 17:13
Show Gist options
  • Save Baekjoon/245366d12cb61eb9bf01 to your computer and use it in GitHub Desktop.
Save Baekjoon/245366d12cb61eb9bf01 to your computer and use it in GitHub Desktop.
8895
#include <iostream>
using namespace std;
long long d[21][21][21];
int main() {
d[1][1][1] = 1LL;
for (int i=2; i<=20; i++) {
for (int j=1; j<=20; j++) {
for (int k=1; k<=20; k++) {
d[i][j][k] = d[i-1][j-1][k] + d[i-1][j][k-1] + d[i-1][j][k] * (i-2);
}
}
}
int t;
cin >> t;
while (t--) {
int n, l, r;
cin >> n >> l >> r;
cout << d[n][l][r] << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment