結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 86 ms
15,060 KB
testcase_02 AC 79 ms
15,204 KB
testcase_03 AC 80 ms
15,208 KB
testcase_04 AC 80 ms
15,284 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 AC 80 ms
15,056 KB
testcase_08 AC 80 ms
15,208 KB
testcase_09 WA -
testcase_10 AC 79 ms
15,144 KB
testcase_11 AC 79 ms
15,104 KB
testcase_12 WA -
testcase_13 AC 79 ms
15,228 KB
testcase_14 WA -
testcase_15 AC 258 ms
15,276 KB
testcase_16 WA -
testcase_17 AC 82 ms
15,148 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 184 ms
15,404 KB
testcase_22 WA -
testcase_23 AC 228 ms
15,252 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 254 ms
15,296 KB
testcase_30 AC 84 ms
15,176 KB
testcase_31 WA -
testcase_32 AC 171 ms
15,220 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 223 ms
15,408 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 107 ms
15,316 KB
testcase_40 WA -
testcase_41 AC 129 ms
15,412 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

gcd = p.gcd(q)
p /= gcd
q /= gcd
type = [p,q]==[0,0] ? 0 : [p,q]==[1,1] ? 1 : p.odd?&&q.odd? ? 2 : 3

count = 0
gets.to_i.times{
	x, y = gets.split.map(&:to_i).map(&:abs)
	
	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
}
puts count
0