Submission #171938

#TimeUsernameProblemLanguageResultExecution timeMemory
171938arnold518Asceticism (JOI18_asceticism)C++14
49 / 100
3 ms632 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 3000; const ll MOD = 1e9+7; int N, K; ll mypow(ll x, ll y) { if(y==0) return 1; if(y%2) return mypow(x, y-1)*x%MOD; ll t=mypow(x, y/2); return t*t%MOD; } ll inv(ll x) { return mypow(x, MOD-2); } ll fact[MAXN+10], invfact[MAXN+10]; ll comb(ll n, ll r) { return fact[n]*invfact[r]%MOD*invfact[n-r]%MOD; } int main() { int i, j; scanf("%d%d", &N, &K); fact[0]=1; for(i=1; i<=N+5; i++) fact[i]=fact[i-1]*i%MOD; invfact[N+5]=inv(fact[N+5]); for(i=N+5; i>=1; i--) invfact[i-1]=invfact[i]*i%MOD; ll ans=0; for(i=0; i<=K; i++) { if(i%2) ans-=mypow(K-i, N)*comb(N+1, i)%MOD; else ans+=mypow(K-i, N)*comb(N+1, i)%MOD; ans%=MOD; ans+=MOD; ans%=MOD; } printf("%lld", ans); }

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:29:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
asceticism.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &K);
     ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...