結果

問題 No.988 N×Mマス計算(総和)
ユーザー gemmarogemmaro
提出日時 2020-02-14 22:22:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 11,544 KB
実行使用メモリ 26,760 KB
最終ジャッジ日時 2023-09-20 11:59:36
合計ジャッジ時間 3,770 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,292 KB
testcase_01 AC 77 ms
15,000 KB
testcase_02 AC 83 ms
15,244 KB
testcase_03 AC 79 ms
15,236 KB
testcase_04 AC 78 ms
15,344 KB
testcase_05 AC 78 ms
15,076 KB
testcase_06 AC 77 ms
15,224 KB
testcase_07 AC 78 ms
15,152 KB
testcase_08 AC 77 ms
15,332 KB
testcase_09 AC 78 ms
15,124 KB
testcase_10 AC 125 ms
17,264 KB
testcase_11 AC 121 ms
22,432 KB
testcase_12 AC 183 ms
26,560 KB
testcase_13 AC 109 ms
20,616 KB
testcase_14 AC 113 ms
20,724 KB
testcase_15 AC 113 ms
16,296 KB
testcase_16 AC 144 ms
21,556 KB
testcase_17 AC 157 ms
24,076 KB
testcase_18 AC 116 ms
22,692 KB
testcase_19 AC 148 ms
25,024 KB
testcase_20 AC 183 ms
26,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

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

ROW = gets.chomp.split
OP = ROW[0].intern
BS = ROW[1..-1].map(&:to_i)

AS = N.times.map do
  gets.to_i
end

puts(case OP
     when :+
       ((AS.sum * M) % K + (BS.sum * N) % K) % K
     else
       BS_SUM = BS.sum
       AS.map { |a| (a * BS_SUM) % K }.sum % K
     end)
0