結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | siman |
提出日時 | 2020-02-14 21:56:29 |
言語 | Ruby (3.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 471 bytes |
コンパイル時間 | 864 ms |
コンパイル使用メモリ | 11,460 KB |
実行使用メモリ | 31,268 KB |
最終ジャッジ日時 | 2023-08-10 01:54:00 |
合計ジャッジ時間 | 3,870 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
15,008 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 71 ms
15,292 KB |
testcase_04 | WA | - |
testcase_05 | AC | 70 ms
15,212 KB |
testcase_06 | AC | 70 ms
15,312 KB |
testcase_07 | WA | - |
testcase_08 | AC | 69 ms
15,092 KB |
testcase_09 | AC | 72 ms
15,216 KB |
testcase_10 | AC | 144 ms
23,320 KB |
testcase_11 | AC | 158 ms
24,972 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 152 ms
23,188 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 209 ms
31,056 KB |
コンパイルメッセージ
Syntax OK
ソースコード
class Integer def mod_inverse(mod) self.pow(mod - 2, mod) end end N, M, K = gets.split.map(&:to_i) op, *B = gets.chomp.split B.map!(&:to_i) A = N.times.map { gets.to_i } ans = 0 mod_counter = Hash.new(0) B.each do |b| mod_counter[b % K] += 1 end A.each do |a| if op == '+' mk = a % K ans += mod_counter[K - mk] else if a % K == 0 ans += M else ans += mod_counter[0] + mod_counter[a.mod_inverse(K)] end end end puts ans