結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー LeonardoneLeonardone
提出日時 2015-12-15 02:32:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 815 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,464 KB
実行使用メモリ 15,504 KB
最終ジャッジ日時 2023-09-21 03:23:33
合計ジャッジ時間 9,381 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,152 KB
testcase_01 AC 82 ms
15,236 KB
testcase_02 AC 82 ms
15,148 KB
testcase_03 AC 83 ms
15,160 KB
testcase_04 AC 83 ms
15,252 KB
testcase_05 AC 83 ms
15,156 KB
testcase_06 AC 83 ms
15,368 KB
testcase_07 AC 82 ms
15,200 KB
testcase_08 AC 81 ms
15,148 KB
testcase_09 AC 83 ms
15,296 KB
testcase_10 AC 83 ms
15,264 KB
testcase_11 AC 83 ms
15,208 KB
testcase_12 AC 83 ms
15,188 KB
testcase_13 AC 83 ms
15,312 KB
testcase_14 AC 218 ms
15,376 KB
testcase_15 AC 276 ms
15,400 KB
testcase_16 AC 156 ms
15,328 KB
testcase_17 AC 85 ms
15,308 KB
testcase_18 AC 178 ms
15,264 KB
testcase_19 AC 207 ms
15,300 KB
testcase_20 AC 275 ms
15,152 KB
testcase_21 AC 213 ms
15,408 KB
testcase_22 AC 113 ms
15,064 KB
testcase_23 AC 267 ms
15,456 KB
testcase_24 AC 125 ms
15,280 KB
testcase_25 AC 190 ms
15,328 KB
testcase_26 AC 266 ms
15,356 KB
testcase_27 AC 218 ms
15,292 KB
testcase_28 AC 224 ms
15,444 KB
testcase_29 AC 314 ms
15,480 KB
testcase_30 AC 90 ms
15,504 KB
testcase_31 AC 86 ms
15,180 KB
testcase_32 AC 197 ms
15,296 KB
testcase_33 AC 179 ms
15,296 KB
testcase_34 AC 157 ms
15,188 KB
testcase_35 AC 259 ms
15,184 KB
testcase_36 AC 90 ms
15,180 KB
testcase_37 AC 205 ms
15,484 KB
testcase_38 AC 182 ms
15,416 KB
testcase_39 AC 117 ms
15,184 KB
testcase_40 AC 269 ms
15,288 KB
testcase_41 AC 139 ms
15,288 KB
testcase_42 AC 237 ms
15,388 KB
testcase_43 AC 162 ms
15,416 KB
testcase_44 AC 227 ms
15,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

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
0