Submission #679174

#TimeUsernameProblemLanguageResultExecution timeMemory
679174rainboyAsceticism (JOI18_asceticism)C11
100 / 100
9 ms1492 KiB
#include <stdio.h> #define N 100000 #define MD 1000000007 int vv[N + 2], ff[N + 2], gg[N + 2]; void init() { int i; ff[0] = gg[0] = 1; for (i = 1; i <= N + 1; i++) { vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD; ff[i] = (long long) ff[i - 1] * i % MD; gg[i] = (long long) gg[i - 1] * vv[i] % MD; } } int choose(int n, int k) { return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD; } long long power(long long a, int k) { long long p = 1; while (k) { if (k & 1) p = p * a % MD; a = a * a % MD; k >>= 1; } return p; } int main() { int n, k, m, ans; init(); scanf("%d%d", &n, &k); ans = 0; for (m = 0; m <= k; m++) ans = (ans + power(m, n) * choose(n + 1, k - m) * ((k - m) % 2 == 0 ? 1 : -1)) % MD; if (ans < 0) ans += MD; printf("%d\n", ans); return 0; }

Compilation message (stderr)

asceticism.c: In function 'main':
asceticism.c:39:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  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...