Submission #44049

#TimeUsernameProblemLanguageResultExecution timeMemory
44049wxh010910Asceticism (JOI18_asceticism)C++17
100 / 100
14 ms1408 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back #define Debug(...) fprintf(stderr, __VA_ARGS__) typedef long long LL; typedef long double LD; typedef unsigned int uint; typedef pair <int, int> pii; typedef unsigned long long uLL; template <typename T> inline void Read(T &x) { char c = getchar(); bool f = false; for (x = 0; !isdigit(c); c = getchar()) { if (c == '-') { f = true; } } for (; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } if (f) { x = -x; } } template <typename T> inline bool CheckMax(T &a, const T &b) { return a < b ? a = b, true : false; } template <typename T> inline bool CheckMin(T &a, const T &b) { return a > b ? a = b, true : false; } const int N = 100005; const int mod = 1e9 + 7; int n, m, ans, fac[N], inv[N]; inline int Qow(int x, int y) { int r = 1; for (; y; y >>= 1, x = 1LL * x * x % mod) { if (y & 1) { r = 1LL * r * x % mod; } } return r; } inline int C(int x, int y) { return 1LL * fac[x] * inv[y] % mod * inv[x - y] % mod; } int main() { #ifdef wxh010910 freopen("d.in", "r", stdin); #endif Read(n), Read(m), fac[0] = fac[1] = inv[0] = inv[1] = 1; for (int i = 2; i <= n + 1; ++i) { fac[i] = 1LL * fac[i - 1] * i % mod; inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod; } for (int i = 2; i <= n + 1; ++i) { inv[i] = 1LL * inv[i - 1] * inv[i] % mod; } for (int i = 0; i <= m; ++i) { if (i & 1) { ans = (ans - 1LL * C(n + 1, i) * Qow(m - i, n) % mod + mod) % mod; } else { ans = (1LL * C(n + 1, i) * Qow(m - i, n) + ans) % mod; } } printf("%d\n", ans); #ifdef wxh010910 Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC); #endif 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...