結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー simansiman
提出日時 2023-04-16 21:41:14
言語 Ruby
(3.3.0)
結果
AC  
実行時間 200 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-20 08:22:40
合計ジャッジ時間 8,124 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
12,160 KB
testcase_01 AC 74 ms
12,416 KB
testcase_02 AC 74 ms
12,288 KB
testcase_03 AC 73 ms
12,160 KB
testcase_04 AC 74 ms
12,288 KB
testcase_05 AC 72 ms
12,160 KB
testcase_06 AC 74 ms
12,416 KB
testcase_07 AC 74 ms
12,288 KB
testcase_08 AC 76 ms
12,160 KB
testcase_09 AC 74 ms
12,160 KB
testcase_10 AC 74 ms
12,160 KB
testcase_11 AC 74 ms
12,288 KB
testcase_12 AC 74 ms
12,288 KB
testcase_13 AC 76 ms
12,160 KB
testcase_14 AC 162 ms
12,288 KB
testcase_15 AC 191 ms
12,288 KB
testcase_16 AC 120 ms
12,544 KB
testcase_17 AC 73 ms
12,160 KB
testcase_18 AC 133 ms
12,544 KB
testcase_19 AC 155 ms
12,288 KB
testcase_20 AC 194 ms
12,288 KB
testcase_21 AC 152 ms
12,288 KB
testcase_22 AC 95 ms
12,288 KB
testcase_23 AC 176 ms
12,416 KB
testcase_24 AC 100 ms
12,416 KB
testcase_25 AC 144 ms
12,544 KB
testcase_26 AC 189 ms
12,544 KB
testcase_27 AC 164 ms
12,288 KB
testcase_28 AC 158 ms
12,544 KB
testcase_29 AC 200 ms
12,416 KB
testcase_30 AC 82 ms
12,416 KB
testcase_31 AC 80 ms
12,160 KB
testcase_32 AC 141 ms
12,544 KB
testcase_33 AC 136 ms
12,544 KB
testcase_34 AC 119 ms
12,288 KB
testcase_35 AC 178 ms
12,416 KB
testcase_36 AC 80 ms
12,288 KB
testcase_37 AC 152 ms
12,544 KB
testcase_38 AC 135 ms
12,416 KB
testcase_39 AC 93 ms
12,288 KB
testcase_40 AC 190 ms
12,416 KB
testcase_41 AC 108 ms
12,288 KB
testcase_42 AC 174 ms
12,544 KB
testcase_43 AC 124 ms
12,416 KB
testcase_44 AC 164 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

P, Q = gets.split.map(&:to_i)
N = gets.to_i

gcd = P.gcd(Q)
ans = 0

N.times do
  x, y = gets.split.map(&:to_i)

  if P == 0 && Q == 0
    ans += 1 if x == 0 && y == 0
  elsif P == 0
    ans += 1 if x % Q == 0 && y % Q == 0
  elsif Q == 0
    ans += 1 if x % P == 0 && y % P == 0
  else
    v = (P / gcd) + (Q / gcd)

    if v % 2 == 0
      m = x / gcd + y / gcd
      ans += 1 if x % gcd == 0 && y % gcd == 0 && m % 2 == 0
    else
      ans += 1 if x % gcd == 0 && y % gcd == 0
    end
  end
end

puts ans
0