結果
問題 | No.995 タピオカオイシクナーレ |
ユーザー |
![]() |
提出日時 | 2020-02-22 05:19:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 2,340 ms |
コンパイル使用メモリ | 193,748 KB |
最終ジャッジ日時 | 2025-01-09 01:48:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int64_t mod = 1000000007; int64_t power(int64_t n, int64_t k) { if (k == 0) return 1; int64_t ans = power(n * n % mod, k / 2); if (k % 2) ans = ans * n % mod; return ans; } int main() { int64_t n, m, k, p, q, s0 = 0, s = 0; cin >> n >> m >> k >> p >> q; for (int i = 0; i < n; i++) { int64_t b; cin >> b; s += b; if (i < m) s0 += b; } s %= mod; s0 %= mod; int64_t shalf = s * ((mod + 1) / 2) % mod, d = (s0 - shalf + mod) % mod; int64_t pq = (1 - 2 * p * power(q, mod - 2) % mod + mod) % mod; cout << (shalf + d * power(pq, k)) % mod << endl; }