結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | siman |
提出日時 | 2020-02-14 23:53:43 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 578 bytes |
コンパイル時間 | 69 ms |
コンパイル使用メモリ | 11,452 KB |
実行使用メモリ | 35,320 KB |
最終ジャッジ日時 | 2023-08-10 03:02:55 |
合計ジャッジ時間 | 5,300 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 80 ms
19,632 KB |
testcase_01 | AC | 81 ms
15,056 KB |
testcase_02 | AC | 81 ms
15,064 KB |
testcase_03 | AC | 78 ms
15,168 KB |
testcase_04 | AC | 80 ms
15,224 KB |
testcase_05 | AC | 79 ms
15,104 KB |
testcase_06 | AC | 80 ms
15,112 KB |
testcase_07 | AC | 81 ms
15,008 KB |
testcase_08 | AC | 80 ms
15,220 KB |
testcase_09 | AC | 80 ms
15,008 KB |
testcase_10 | AC | 178 ms
23,616 KB |
testcase_11 | AC | 195 ms
24,996 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_a = a.gcd(K) gcd_counter.each do |e, cnt| ans += cnt if (e * gcd_a) % K == 0 end end end end puts ans