結果
問題 |
No.321 (P,Q)-サンタと街の子供たち
|
ユーザー |
![]() |
提出日時 | 2015-12-14 22:41:32 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 417 bytes |
コンパイル時間 | 92 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-09-15 12:44:09 |
合計ジャッジ時間 | 6,538 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 WA * 29 RE * 2 |
コンパイルメッセージ
Syntax OK
ソースコード
p, q = gets.split.map(&:to_i).map(&:abs) gcd = p.gcd(q) p /= gcd q /= gcd type = [p,q]==[0,0] ? 0 : [p,q]==[1,1] ? 1 : p.odd?&&q.odd? ? 2 : 3 count = 0 gets.to_i.times{ x, y = gets.split.map(&:to_i).map(&:abs) break if x % gcd != 0 || y % gcd != 0 x %= gcd; y %= gcd case type when 0 count += 1 when 1 count += 1 if (x+y).even? when 2 count += 1 if (x+y).even? when 3 count += 1 end } puts count