#include <iostream> using namespace std; int symbolNewtona(int n, int k) { if (k == n || k == 0) return 1; return symbolNewtona(n-1, k-1) + symbolNewtona(n-1, k); } int main() { int n, k; scanf("%d %d", &n, &k); n = k+n-1; printf("%d\n",symbolNewtona(n,k)%1000000007); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <iostream> using namespace std; int symbolNewtona(int n, int k) { if (k == n || k == 0) return 1; return symbolNewtona(n-1, k-1) + symbolNewtona(n-1, k); } int main() { int n, k; scanf("%d %d", &n, &k); n = k+n-1; printf("%d\n",symbolNewtona(n,k)%1000000007); return 0; } |