結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー LeonardoneLeonardone
提出日時 2015-12-15 02:20:10
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-09-15 12:57:41
合計ジャッジ時間 9,324 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 18 WA * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#! 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


c = 0

N.times do
    x, y = gis.map(&:abs)
    
    if P == 0 && Q == 0
        c += 1 if x == 0 && y == 0
        next
    end
    if P == 0
        c += 1 if x % Q == 0 && y % Q == 0
        next
    end
    if Q == 0
        c += 1 if x % P == 0 && y % P == 0
        next
    end
    
    u, v = [x % 2, y % 2].minmax
    
    if u == 0 && v == 1
        c += 1 if P % 2 == 0 || Q % 2 == 0
    else
        c += 1
    end
    
end

p c
0