結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー kura07kura07
提出日時 2015-12-14 23:21:32
言語 Ruby
(3.2.2)
結果
AC  
実行時間 265 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 15,452 KB
最終ジャッジ日時 2023-09-21 03:20:37
合計ジャッジ時間 8,653 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
15,404 KB
testcase_01 AC 87 ms
15,284 KB
testcase_02 AC 83 ms
15,356 KB
testcase_03 AC 84 ms
15,096 KB
testcase_04 AC 84 ms
15,164 KB
testcase_05 AC 84 ms
15,176 KB
testcase_06 AC 81 ms
15,356 KB
testcase_07 AC 83 ms
15,308 KB
testcase_08 AC 82 ms
15,328 KB
testcase_09 AC 82 ms
15,296 KB
testcase_10 AC 82 ms
15,096 KB
testcase_11 AC 84 ms
15,192 KB
testcase_12 AC 84 ms
15,096 KB
testcase_13 AC 83 ms
15,192 KB
testcase_14 AC 203 ms
15,380 KB
testcase_15 AC 262 ms
15,428 KB
testcase_16 AC 149 ms
15,172 KB
testcase_17 AC 84 ms
15,316 KB
testcase_18 AC 165 ms
15,452 KB
testcase_19 AC 195 ms
15,224 KB
testcase_20 AC 249 ms
15,412 KB
testcase_21 AC 189 ms
15,260 KB
testcase_22 AC 113 ms
15,324 KB
testcase_23 AC 234 ms
15,364 KB
testcase_24 AC 120 ms
15,268 KB
testcase_25 AC 176 ms
15,264 KB
testcase_26 AC 243 ms
15,380 KB
testcase_27 AC 203 ms
15,172 KB
testcase_28 AC 204 ms
15,304 KB
testcase_29 AC 265 ms
15,428 KB
testcase_30 AC 91 ms
15,192 KB
testcase_31 AC 86 ms
15,200 KB
testcase_32 AC 174 ms
15,368 KB
testcase_33 AC 168 ms
15,424 KB
testcase_34 AC 145 ms
15,420 KB
testcase_35 AC 222 ms
15,364 KB
testcase_36 AC 88 ms
15,288 KB
testcase_37 AC 189 ms
15,448 KB
testcase_38 AC 167 ms
15,172 KB
testcase_39 AC 109 ms
15,220 KB
testcase_40 AC 244 ms
15,300 KB
testcase_41 AC 127 ms
15,276 KB
testcase_42 AC 221 ms
15,220 KB
testcase_43 AC 150 ms
15,416 KB
testcase_44 AC 206 ms
15,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

p, q = gets.split.map(&:to_i).map(&:abs)

type = nil
if [p,q]==[0,0]
	type = -1
else
	gcd = p.gcd(q)
	p /= gcd
	q /= gcd
	type = p*q==0 ? 0 : [p,q]==[1,1] ? 1 : p.odd?&&q.odd? ? 2 : 3
end

count = 0
gets.to_i.times{
	x, y = gets.split.map(&:to_i).map(&:abs)
	
	if type==-1
		count += 1 if [x,y]==[0,0]
	else
		next 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
	end
}
puts count
0