Submission #361739

#TimeUsernameProblemLanguageResultExecution timeMemory
361739dolphingarlicAsceticism (JOI18_asceticism)C++14
100 / 100
24 ms364 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const ll MOD = 1e9 + 7; ll expo(ll base, ll pow) { ll ans = 1; while (pow) { if (pow & 1) ans = (ans * base) % MOD; base = (base * base) % MOD; pow >>= 1; } return ans; } int main() { int n, k; scanf("%d %d", &n, &k); ll ans = 0, choose = 1, neg = 1; for (int i = 0; i <= k; i++) { ans = (ans + neg * choose % MOD * expo(k - i, n)) % MOD; choose = choose * (n + 1 - i) % MOD * expo(i + 1, MOD - 2) % MOD; neg = MOD - neg; } printf("%lld", ans); return 0; }

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%d %d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...