fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
  4. #define mofile(s) freopen(s,"r",stdin)
  5. #define outfile(s) freopen(s,"w",stdout)
  6. #define ll long long
  7. #define ii pair<ll,ll>
  8. #define iii pair<ll,ii>
  9. #define fi first
  10. #define se second
  11. #define tf bool
  12. #define ST stack
  13. #define DQ deque
  14. #define Q queue
  15. #define S string
  16. #define Ma map
  17. #define UM unormideremid_map
  18. #define SE set
  19. #define str(x) to_string(x)
  20. #define all(a) (a).begin(),(a).end()
  21. #define FOR(i,l,r,mid) for(int i=l;i<=r;i+=mid)
  22. #define FOD(i,l,r,mid) for(int i=r;i>=l;i-=mid)
  23. #define xuong cout<<"\n"
  24. #define midebug(x) cout<<(x)<<" "
  25. #define ppcnt(x) __builtin_popcountll(x)
  26. #define parity(x) __builtin_parityll(x)
  27. #define leamid0(x) __builtin_clzll(x)
  28. #define LOG2 __lg(x)
  29. #define tr0(x) __builtin_ctzll(x)
  30. #define fiset(x) __builtin_ffsll(x)
  31. #define MASK(k) (1LL<<(k))
  32. #define BIT(x,k) ((x)>>(k)&1)
  33. #define pb push_back
  34. #define tron(x) setprecision(x)
  35. #define het return 0
  36. #define base_ 1000000000
  37. template<typename... T>
  38. void in(T&... args) { ((cin >> args), ...); }
  39. template<class X, class Y>
  40. bool maximize(X &x, const Y &y){return (x < y) ? x = y, 1 : 0;}
  41. template<class X, class Y>
  42. bool minimize(X &x, const Y &y){return (x > y) ? x = y, 1 : 0;}
  43. const ll maxn=1e6+5;
  44. const ll tle=2e8;
  45. const ll INF=1e9+9;
  46. const int base=31;
  47. const ll MOD=1e9+7;
  48. const ll P=1e9+7;
  49. string bcc="abcmidefghijklmnopqrstuvwxyz";
  50. int midx[]={-1,0,1,0};
  51. int midy[]={0,1,0,-1};
  52. bool sang[10000005];
  53. ll pref[1005][1005],mt[1005][1005];
  54. void sieve(){
  55. for(int i=1;i<=10000000;++i) sang[i]=1;
  56. sang[0]=sang[1]=0;
  57. for(int i=2;i*i<=10000000;++i){
  58. if(sang[i]){
  59. for(int j=i*i;j<=10000000;j+=i) sang[j]=0;
  60. }
  61. }
  62. }
  63. void lis(){
  64. vector<int>t;
  65. vector<int>a;
  66. int n; cin>>n;
  67. for(int i=1;i<=n;++i){
  68. int ai; cin>>ai;
  69. a.pb(ai);
  70. }
  71. for(int x:a){
  72. auto it=lower_bound(all(t),x);
  73. if(it==t.end()) t.pb(x);
  74. else *it=x;
  75. }
  76. }
  77. void pfs2mid(){
  78. int n,m,k; cin>>n; m=n;
  79. int q; cin>>q;
  80. for(int i=1;i<=n;++i){
  81. for(int j=1;j<=m;++j) cin>>mt[i][j];
  82. }
  83. for(int i=1;i<=n;++i){
  84. for(int j=1;j<=m;++j) pref[i][j]=mt[i][j]+pref[i-1][j]+pref[i][j-1]-pref[i-1][j-1];
  85. }
  86. }
  87. const int M=1e9+7;
  88. long long f[2000005];
  89. long long v[2000005];
  90. long long p(long long a,long long b){
  91. long long r=1;
  92. a%=M;
  93. while(b>0){
  94. if(b&1)r=(r*a)%M;
  95. a=(a*a)%M;
  96. b>>=1;
  97. }
  98. return r;
  99. }
  100. long long inv(long long n){
  101. return p(n,M-2);
  102. }
  103. void c(){
  104. f[0]=1;
  105. v[0]=1;
  106. for(int i=1;i<=2000000;i++){
  107. f[i]=(f[i-1]*i)%M;
  108. v[i]=inv(f[i]);
  109. }
  110. }
  111. long long nC(int n,int k){
  112. if(k<0||k>n)return 0;
  113. return f[n]*v[k]%M*v[n-k]%M;
  114. }
  115. int main(){
  116. ios_base::sync_with_stdio(false);
  117. cin.tie(NULL);
  118. c();
  119. int n,k;
  120. if(cin>>n>>k){
  121. cout<<nC(n+k,k)<<"\n";
  122. }
  123. return 0;
  124. }
Success #stdin #stdout 0.22s 35544KB
stdin
Standard input is empty
stdout
Standard output is empty