提交时间:2024-08-20 20:18:46

运行 ID: 169924

#include <bits/stdc++.h> using namespace std; using ll=long long; const ll mod=1e9+7; ll a(int n,int k) { ll ans = 1; for(int i =0;i<k;i++) { ans*=n; ans; n--; } return ans; } ll mypow(ll a,ll b,ll p) { if(b==0) { return 1; } ll ans =mypow(a,b/2,p); if(b&1) return ans*ans%p*a%p; else return ans*ans%p; } ll inverse(int n,int p) { return mypow(n,p-2,p); } ll c(int n,int k) { return a(n,k)*inverse(a(k,k),mod); } int main() { int n,k; cin>>n>>k; cout<<c(k+n-2,n-1); return 0; }