結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー wonda_t_coffeewonda_t_coffee
提出日時 2020-02-15 00:05:39
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 59 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 25,088 KB
最終ジャッジ日時 2024-04-27 20:40:26
合計ジャッジ時間 4,788 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
11,904 KB
testcase_01 AC 87 ms
12,032 KB
testcase_02 AC 86 ms
12,032 KB
testcase_03 AC 87 ms
12,160 KB
testcase_04 AC 93 ms
12,032 KB
testcase_05 AC 91 ms
12,032 KB
testcase_06 AC 95 ms
12,160 KB
testcase_07 AC 91 ms
12,160 KB
testcase_08 AC 95 ms
12,032 KB
testcase_09 AC 92 ms
12,032 KB
testcase_10 AC 167 ms
20,352 KB
testcase_11 AC 209 ms
18,560 KB
testcase_12 AC 471 ms
24,832 KB
testcase_13 AC 166 ms
17,664 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 194 ms
19,840 KB
testcase_17 WA -
testcase_18 AC 493 ms
24,960 KB
testcase_19 AC 252 ms
20,224 KB
testcase_20 AC 255 ms
25,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - m
Syntax OK

ソースコード

diff #

n, m, k = gets.chomp.split.map(&:to_i)

b = gets.chomp.split
op = b.shift
b.map!(&:to_i)
a = [] * n
h = Hash.new(0)
b.each do |bi|
  h[bi % k] += 1
end
n.times do
  a << gets.chomp.to_i % k
end

if op == '+'
  ans = 0
  a.each do |ai|
    ans += h[k - ai]
  end
  puts ans
  exit
end

ha = Hash.new(0)
hb = Hash.new(0)
a.each do |ai|
  ha[ai.gcd(k)] += 1
end
b.each do |bi|
  hb[bi.gcd(k)] += 1
end

ans = 0
ha.each do |ka, va|
  hb.each do |kb, vb|
    if ka * kb % k == 0
      ans += va * vb
    end
  end
end
puts ans
0