Submission #47472

#TimeUsernameProblemLanguageResultExecution timeMemory
47472Just_Solve_The_ProblemAsceticism (JOI18_asceticism)C++11
0 / 100
5 ms1132 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define ll long long #define pii pair < int, int > #define fr first #define sc second #define mk make_pair #define sz(s) (int)s.size() #define all(s) s.begin(), s.end() #define ok puts("ok"); #define whatis(x) cerr << #x << " = " << x << endl; #define pause system("pause"); #define random rand() ^ (rand() << 5) const int N = (int)1e5 + 7; const int inf = (int)1e9 + 7; int mod = (int)1e9 + 7; ll fact[N]; ll mult(ll a, ll b) { return a * b % mod; } void precalc() { fact[0] = 1; for (ll i = 1; i < N; i++) { fact[i] = mult(fact[i - 1], i); } } ll binpow(ll a, int n) { ll res = 1; while (n > 0) { if (n & 1) { res = mult(res, a); } a = mult(a, a); n >>= 1; } return res; } ll cnk(ll n, ll k) { if (k > n) return 0; return mult(mult(fact[n], binpow(fact[k], mod - 2)), binpow(fact[n - k], mod - 2)); } int n, m; main() { precalc(); scanf("%d %d", &n, &m); m--; ll ans = 0; for (int k = 0; k <= m + 1; k++) { if (k & 1) { ans -= mult(cnk(n + 1, k), binpow(m + 1 - k, n)); } else { ans += mult(cnk(n + 1, k), binpow(m + 1 - k, n)); } } cout << ans; }

Compilation message (stderr)

asceticism.cpp:55:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
asceticism.cpp: In function 'int main()':
asceticism.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...