結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | siman |
提出日時 | 2020-02-14 23:52:34 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 550 bytes |
コンパイル時間 | 374 ms |
コンパイル使用メモリ | 11,428 KB |
実行使用メモリ | 35,620 KB |
最終ジャッジ日時 | 2023-08-10 03:02:33 |
合計ジャッジ時間 | 6,011 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 82 ms
19,620 KB |
testcase_01 | AC | 81 ms
15,072 KB |
testcase_02 | AC | 82 ms
15,332 KB |
testcase_03 | AC | 83 ms
15,096 KB |
testcase_04 | AC | 83 ms
15,028 KB |
testcase_05 | AC | 82 ms
15,056 KB |
testcase_06 | AC | 81 ms
15,300 KB |
testcase_07 | AC | 81 ms
15,328 KB |
testcase_08 | AC | 81 ms
15,084 KB |
testcase_09 | AC | 81 ms
15,132 KB |
testcase_10 | AC | 179 ms
23,472 KB |
testcase_11 | AC | 197 ms
24,828 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
コンパイルメッセージ
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 gcd_counter = Hash.new(0) mod_counter = Hash.new(0) B.each do |b| mod_counter[b % K] += 1 gcd_counter[b.gcd(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 gcd_counter.each do |e, cnt| ans += cnt if (e * a) % K == 0 end end end end puts ans