# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73253 | maus1208 | Asceticism (JOI18_asceticism) | C++14 | 4 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#import<bits/stdc++.h>
using namespace std;
#define sysp system("pause")
#define mod 1000000007
#define rmod 1000000005
typedef long long ll;
ll n,k,ans;
vector<ll> f,rf;
ll mypow(ll x,ll n){
ll ret=1;
while(n>0){
if((n&1)==1){
ret*=x%mod;
}
x*=x%mod;
n>>=1;
}
return ret%mod;
}
void init(){
f[0]=1;
rf[0]=1;
for(ll i=1;i<=100010;i++){
f[i]*=i*f[i-1]%mod;
rf[i]=mypow(f[i],rmod);
}
}
int main(){
cin>>n>>k;
ll tmp=-1;
init();
for(ll i=0;i<=k;i++){
tmp*=-1;
ans+=f[n+1]*rf[i]*rf[n+1-i]*tmp*mypow((k-i+1),n)%mod;
}
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |