Submission #62462

#TimeUsernameProblemLanguageResultExecution timeMemory
62462gusfringAsceticism (JOI18_asceticism)C++14
100 / 100
37 ms2396 KiB
# include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const long long N = 1e5 + 2; long long binpow(long long a, long long n){ long long res = 1; while(n){ if(n & 1) res = (res * a) % mod; a = (a * a) % mod; n >>= 1; } return res; } long long n, k, f[N], fi[N]; long long cnk(long long n, long long k){ return ((f[n] * fi[n - k]) % mod * fi[k]) % mod; } int main(){ f[0] = 1; fi[0] = binpow(f[0], mod - 2); for(long long i = 1; i < N; i ++){ f[i] = (f[i - 1] * i) % mod; fi[i] = binpow(f[i], mod - 2); } scanf("%lld %lld", &n, &k); long long ans = 0; for(long long i = 0; i <= k; i ++){ if(i & 1){ ans -= (cnk(n + 1, i) * binpow(k - i, n)) % mod; if(ans < 0) ans += mod; } else { ans += (cnk(n + 1, i) * binpow(k - i, n)) % mod; if(ans > mod) ans -= mod; } } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &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...