This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 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... |