結果
| 問題 |
No.321 (P,Q)-サンタと街の子供たち
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-15 02:32:44 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 282 ms / 2,000 ms |
| コード長 | 815 bytes |
| コンパイル時間 | 54 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 12,672 KB |
| 最終ジャッジ日時 | 2024-07-06 22:02:23 |
| 合計ジャッジ時間 | 7,762 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 |
コンパイルメッセージ
Syntax OK
ソースコード
#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU
def gs(); gets.chomp; end
def gi(); gets.to_i; end
def gss(); gets.chomp.split; end
def gis(); gss.map(&:to_i); end
# 解説読後
# http://yukicoder.me/problems/849/editorial
P, Q = gis
N = gi
g = P * Q == 0 ? 1 : P.gcd(Q)
pg = P / g
qg = Q / g
c = 0
N.times do
x, y = gis.map(&:abs)
if x == 0 && y == 0
c += 1
next
end
if P == 0
c += 1 if Q > 0 && x % Q == 0 && y % Q == 0
next
end
if Q == 0
c += 1 if x % P == 0 && y % P == 0
next
end
next if x % g > 0 || y % g > 0
x /= g
y /= g
u, v = [x % 2, y % 2].minmax
if u == 0 && v == 1
c += 1 if pg % 2 == 0 || qg % 2 == 0
else
c += 1
end
end
p c