样例解释
转换成路径问题
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const int mod = 1e9 + 7; 5 ll qmi(ll a, ll b, ll p) { 6 ll res = 1; 7 while (b) { 8 if (b & 1) { 9 res = res * a % p; 10 } 11 a = a * a % p; 12 b >>= 1; 13 } 14 return res; 15 } 16 int main() { 17 int n; 18 cin >> n; 19 //C(2n, n) / (n + 1) 20 int a = 2 * n, b = n; 21 ll res = 1; 22 for (int i = 1, j = a; i <= b; i++, j--) { 23 res = res * j % mod; 24 res = res * qmi(i, mod - 2, mod) % mod; 25 } 26 res = res * qmi(n + 1, mod - 2, mod) % mod; 27 cout << res << endl; 28 return 0; 29 }