結果

問題 No.1972 Modulo Set
ユーザー simansiman
提出日時 2022-06-11 09:37:55
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 327 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 11,896 KB
実行使用メモリ 27,560 KB
最終ジャッジ日時 2023-10-21 16:54:28
合計ジャッジ時間 9,188 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
20,476 KB
testcase_01 AC 86 ms
16,100 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 107 ms
18,772 KB
testcase_06 AC 119 ms
20,188 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 93 ms
16,360 KB
testcase_10 WA -
testcase_11 AC 136 ms
22,544 KB
testcase_12 AC 95 ms
17,080 KB
testcase_13 AC 105 ms
16,624 KB
testcase_14 AC 100 ms
16,624 KB
testcase_15 AC 142 ms
22,696 KB
testcase_16 AC 153 ms
23,976 KB
testcase_17 WA -
testcase_18 AC 88 ms
16,100 KB
testcase_19 AC 149 ms
22,716 KB
testcase_20 AC 155 ms
23,848 KB
testcase_21 AC 113 ms
19,316 KB
testcase_22 AC 144 ms
21,996 KB
testcase_23 AC 381 ms
27,404 KB
testcase_24 AC 327 ms
19,572 KB
testcase_25 AC 397 ms
22,224 KB
testcase_26 AC 165 ms
26,336 KB
testcase_27 AC 478 ms
27,560 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

counter = A.map { |a| a % M }.tally
counter.default = 0

ans = [1, counter[0]].min

1.upto(M / 2) do |i|
  j = M - i
  g1 = i.gcd(M)
  g2 = j.gcd(M)

  cnt_1 = [counter[i], M / g1 - 1].min
  cnt_2 = [counter[j], M / g2 - 1].min
  ans += [cnt_1, cnt_2].max
end

puts ans
0