Submission #132835

#TimeUsernameProblemLanguageResultExecution timeMemory
132835dualityAsceticism (JOI18_asceticism)C++11
100 / 100
26 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef long long int LLI; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vpii; #define MOD 1000000007 LLI modPow(LLI b,int e) { LLI r = 1; while (e > 0) { if (e & 1) r *= b,r %= MOD; e >>= 1; b *= b,b %= MOD; } return r; } int main() { int N,K; cin >> N >> K; int i; LLI ans = 0,c = 1; for (i = 0; i < K; i++) { if (!(i & 1)) ans += modPow(K-i,N)*c,ans %= MOD; else ans -= modPow(K-i,N)*c,ans %= MOD; c *= (N+1-i),c %= MOD; c *= modPow(i+1,MOD-2),c %= MOD; } if (ans < 0) ans += MOD; cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...