結果

問題 No.995 タピオカオイシクナーレ
ユーザー ikdikd
提出日時 2020-02-21 23:05:50
言語 Nim
(2.0.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 5,449 ms
コンパイル使用メモリ 68,236 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-30 07:53:18
合計ジャッジ時間 6,656 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 54 ms
4,380 KB
testcase_17 AC 53 ms
4,376 KB
testcase_18 AC 54 ms
4,376 KB
testcase_19 AC 53 ms
4,380 KB
testcase_20 AC 53 ms
4,380 KB
testcase_21 AC 53 ms
4,376 KB
testcase_22 AC 54 ms
4,380 KB
testcase_23 AC 54 ms
4,380 KB
testcase_24 AC 54 ms
4,380 KB
testcase_25 AC 54 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

const mo: int64 = 1000000000 + 7
proc mpow(a, x: int64): int64 =
  if x == 0: return 1
  if x == 1: return a
  if x mod 2 == 0: return mpow(a * a mod mo, x div 2)
  return mpow(a, x - 1) * a mod mo

proc mdiv(a, b: int64): int64 =
  return a mod mo * mpow(b mod mo, mo - 2) mod mo

proc main() =
  var n, m, k, p, q: int64
  (n, m, k, p, q) = stdin.readLine.strip.split.map(parseBiggestInt)
  let a = newSeqWith(n.int, stdin.readLine.strip.parseBiggestInt)

  let
    s = (1 - mdiv(p, q) * 2 mod mo + mo) mod mo
    t = mpow(s, k)
    u = t * mdiv(1, 2) mod mo
    v = t * (-mdiv(1, 2) + mo) mod mo
  var ans: int64 = 0
  for i in 0..<a.len:
    let w = if i < m: u else: v
    ans = (ans + (w + mdiv(1, 2)) mod mo * a[i] mod mo) mod mo
  echo ans
main()
0