Submission #319732

#TimeUsernameProblemLanguageResultExecution timeMemory
319732BeanZAsceticism (JOI18_asceticism)C++14
100 / 100
66 ms1132 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; //#define task "A" #define ll long long #define endl '\n' const int N = 1e5 + 10; const int mod = 1e9 + 7; ll fact[N]; ll binpow(ll u, ll p){ if (p == 0) return 1; if (p == 1) return u; ll t = binpow(u, p / 2); if (p & 1) return t * t % mod * u % mod; else return t * t % mod; } ll nCk(ll n, ll k){ return fact[n] * binpow(fact[n - k], mod - 2) % mod * binpow(fact[k], mod - 2) % mod; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen(".inp", "r")){ freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } ll n, m; cin >> n >> m; m--; fact[0] = 1; for (int i = 1; i <= (n + 1); i++) fact[i] = fact[i - 1] * i % mod; ll p = -1; ll ans = 0; for (int i = 0; i <= (m + 1); i++){ p = p * -1; ans = (ans + p * nCk(n + 1, i) * binpow(m + 1 - i, n) + 1ll * mod * mod) % mod; } cout << ans; } /* */

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   24 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
asceticism.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         freopen(".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...