Submission #635382

#TimeUsernameProblemLanguageResultExecution timeMemory
635382MahdiSumtree (INOI20_sumtree)C++17
10 / 100
8 ms4196 KiB
#include<bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; #define all(v) v.begin(), v.end() #define F first #define S second typedef long long ll; typedef pair<int, int> pii; const int N=5e5+5, M=1e9+7; int n, r, f[N], rf[N]; int tav(int a, int b){ int res=1; while(b){ if(b&1) res=1LL*res*a%M; a=1LL*a*a%M; b>>=1; } return res; } int C(int x, int y){ ll res=1LL*f[x]*rf[y]%M; res=res*rf[x-y]%M; return res; } int main(){ cin>>n>>r; f[0]=1; for(int i=1;i<N;++i) f[i]=1LL*f[i-1]*i%M; rf[N-1]=tav(f[N-1], M-2); for(int i=N-2;i>=0;--i) rf[i]=1LL*(i+1)*rf[i+1]%M; cout<<C(r+n-1, n-1)<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...