結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー yuruhiya
提出日時 2021-01-24 14:21:00
言語 Crystal
(1.14.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 11,082 ms
コンパイル使用メモリ 295,620 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 22:11:32
合計ジャッジ時間 14,803 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

lib C
  fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end

class String
  def to_i64
    C.strtoll(self, nil, 10)
  end
end

p, q = read_line.split.map(&.to_i64)
n = read_line.to_i
g = p.gcd(q)
if g > 0
  p //= g
  q //= g
end
puts (0...n).count {
  x, y = read_line.split.map(&.to_i64)
  if g == 0
    {x, y} == {0, 0}
  elsif (p + q).even?
    {x % g, y % g} == {0, 0} && (x // g + y // g).even?
  else
    {x % g, y % g} == {0, 0}
  end
}
0