結果

問題 No.1343 Dividing Digit
ユーザー simansiman
提出日時 2021-01-21 19:50:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 180 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 11,296 KB
実行使用メモリ 21,676 KB
最終ジャッジ日時 2023-08-26 06:52:09
合計ジャッジ時間 4,789 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
15,180 KB
testcase_01 AC 70 ms
15,116 KB
testcase_02 AC 70 ms
15,156 KB
testcase_03 AC 118 ms
21,140 KB
testcase_04 AC 71 ms
15,424 KB
testcase_05 AC 83 ms
16,732 KB
testcase_06 AC 76 ms
15,852 KB
testcase_07 AC 86 ms
17,176 KB
testcase_08 AC 109 ms
19,824 KB
testcase_09 AC 106 ms
20,460 KB
testcase_10 AC 75 ms
15,688 KB
testcase_11 AC 86 ms
16,976 KB
testcase_12 AC 102 ms
19,392 KB
testcase_13 AC 100 ms
19,136 KB
testcase_14 AC 75 ms
15,692 KB
testcase_15 AC 88 ms
16,944 KB
testcase_16 AC 79 ms
15,544 KB
testcase_17 AC 109 ms
20,152 KB
testcase_18 AC 115 ms
21,292 KB
testcase_19 AC 99 ms
19,068 KB
testcase_20 AC 88 ms
18,028 KB
testcase_21 AC 103 ms
20,008 KB
testcase_22 AC 104 ms
20,224 KB
testcase_23 AC 116 ms
21,676 KB
testcase_24 AC 115 ms
21,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

ans = 0
x = 1
mod = A.sum

A.reverse_each.with_index do |a|
  ans += a * x
  ans %= mod
  x *= K
  x %= mod
end

puts ans
0