結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー kura07kura07
提出日時 2015-12-14 22:47:43
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 527 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 11,320 KB
実行使用メモリ 15,432 KB
最終ジャッジ日時 2023-10-13 16:46:54
合計ジャッジ時間 6,513 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,336 KB
testcase_01 AC 78 ms
15,236 KB
testcase_02 AC 79 ms
15,140 KB
testcase_03 AC 79 ms
15,268 KB
testcase_04 AC 80 ms
15,312 KB
testcase_05 AC 79 ms
15,240 KB
testcase_06 WA -
testcase_07 AC 81 ms
15,128 KB
testcase_08 AC 80 ms
15,104 KB
testcase_09 WA -
testcase_10 AC 79 ms
15,112 KB
testcase_11 AC 80 ms
15,164 KB
testcase_12 WA -
testcase_13 AC 80 ms
15,080 KB
testcase_14 WA -
testcase_15 AC 260 ms
15,280 KB
testcase_16 WA -
testcase_17 AC 81 ms
15,060 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 182 ms
15,180 KB
testcase_22 WA -
testcase_23 AC 228 ms
15,320 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 256 ms
15,168 KB
testcase_30 AC 83 ms
15,160 KB
testcase_31 WA -
testcase_32 AC 168 ms
15,180 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 218 ms
15,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 113 ms
15,432 KB
testcase_40 WA -
testcase_41 AC 125 ms
15,276 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
		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
	end
}
puts count
0