Submission #128239

#TimeUsernameProblemLanguageResultExecution timeMemory
128239RockyBAsceticism (JOI18_asceticism)C++17
49 / 100
100 ms56824 KiB
#include <bits/stdc++.h> #define f first #define s second #define pb push_back #define pp pop_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define rep(a, b, c) for (int a = (b); (a) <= (c); ++a) #define per(a, b, c) for (int a = (b); (a) >= (c); --a) #define nl '\n' #define ioi exit(0); using namespace std; typedef long long ll; const int MAX_N = (int)3e3 + 7; const int mod = (int)1e9 + 7; int n, k; int c[MAX_N][MAX_N]; int bp(int x, int y) { int res = 1; while (y) { if (y & 1) res = res * 1ll * x % mod; x = x * 1ll * x % mod, y >>= 1; } return res; } int main() { #ifdef IOI freopen ("in.txt", "r", stdin); #endif cin >> n >> k; rep(i, 0, n + 1) { c[i][0] = 1; rep(j, 1, i) { c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod; } } int ans = 0; k--; rep(i, 0, k) { int x = bp(-1, i) * 1ll * c[n + 1][i] % mod; x = x * 1ll * bp(k - i + 1, n) % mod; ans += x; ans %= mod; ans += mod; ans %= mod; } cout << ans; //cout << dp[n][k]; ioi }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...