Submission #1026741

#TimeUsernameProblemLanguageResultExecution timeMemory
1026741modwweAsceticism (JOI18_asceticism)C++17
100 / 100
8 ms2136 KiB
#include<bits/stdc++.h> #define ll long long #define pll pair<ll, ll> #define pb push_back #define mp make_pair #define fi first #define se second #define ld long double #define sz(a) ((ll)(a).size()) using namespace std; const ll maxn=100005, Mod=1e9+7; ll po[maxn], inv[maxn]; ll C(ll k, ll n){return po[n]*inv[k]%Mod*inv[n-k]%Mod;} ll binpow(ll a, ll k) { ll ans=1; for (; k; a=a*a%Mod, k>>=1) if (k&1) ans=ans*a%Mod; return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, k; cin >> n >> k; for (ll i=0; i<maxn; i++) po[i]=i?po[i-1]*i%Mod:1; inv[maxn-1]=binpow(po[maxn-1], Mod-2); for (ll i=maxn-2; i>=0; i--) inv[i]=inv[i+1]*(i+1)%Mod; ll ans=0; for (ll i=0; i<k; i++) ans+=(i&1?-1:1)*C(i, n+1)*binpow(k-i, n)%Mod; cout << (ans%Mod+Mod)%Mod; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...