結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー cielciel
提出日時 2015-12-14 04:51:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 11,540 KB
実行使用メモリ 15,468 KB
最終ジャッジ日時 2023-09-21 03:18:50
合計ジャッジ時間 8,231 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,336 KB
testcase_01 AC 83 ms
15,328 KB
testcase_02 AC 82 ms
15,276 KB
testcase_03 AC 82 ms
15,340 KB
testcase_04 AC 83 ms
15,272 KB
testcase_05 AC 84 ms
15,132 KB
testcase_06 AC 82 ms
15,276 KB
testcase_07 AC 83 ms
15,164 KB
testcase_08 AC 81 ms
15,156 KB
testcase_09 AC 82 ms
15,156 KB
testcase_10 AC 82 ms
15,168 KB
testcase_11 AC 83 ms
15,164 KB
testcase_12 AC 83 ms
15,272 KB
testcase_13 AC 83 ms
15,296 KB
testcase_14 AC 166 ms
15,468 KB
testcase_15 AC 226 ms
15,424 KB
testcase_16 AC 131 ms
15,276 KB
testcase_17 AC 84 ms
15,240 KB
testcase_18 AC 143 ms
15,144 KB
testcase_19 AC 163 ms
15,304 KB
testcase_20 AC 204 ms
15,288 KB
testcase_21 AC 165 ms
15,168 KB
testcase_22 AC 103 ms
15,268 KB
testcase_23 AC 198 ms
15,032 KB
testcase_24 AC 110 ms
15,244 KB
testcase_25 AC 148 ms
15,244 KB
testcase_26 AC 199 ms
15,356 KB
testcase_27 AC 167 ms
15,452 KB
testcase_28 AC 170 ms
15,396 KB
testcase_29 AC 227 ms
15,308 KB
testcase_30 AC 86 ms
15,196 KB
testcase_31 AC 85 ms
15,164 KB
testcase_32 AC 157 ms
15,152 KB
testcase_33 AC 145 ms
15,144 KB
testcase_34 AC 137 ms
15,420 KB
testcase_35 AC 264 ms
15,412 KB
testcase_36 AC 86 ms
15,176 KB
testcase_37 AC 171 ms
15,264 KB
testcase_38 AC 157 ms
15,376 KB
testcase_39 AC 116 ms
15,292 KB
testcase_40 AC 219 ms
15,356 KB
testcase_41 AC 138 ms
15,300 KB
testcase_42 AC 192 ms
15,284 KB
testcase_43 AC 141 ms
15,444 KB
testcase_44 AC 177 ms
15,240 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
def egcd(x,y)
	return [x,1,0] if y==0
	g,a,b=egcd(y,x%y)
	[g,b,a-x/y*b]
end

a,b=gets.split.map(&:to_i).sort
gets
if b==0
	p $<.count{|e|
		x,y=e.split.map(&:to_i)
		x==0&&y==0
	}
else
	g,z1,z2=egcd(a,b)
	a/=g
	b/=g
	p $<.count{|e|
		x,y=e.split.map(&:to_i)
		next if x%g!=0 || y%g!=0
		x/=g
		y/=g
		(y-z2*x*a-z1*x*b)%(2*a).gcd(2*b).gcd(b*b-a*a)==0
	}
end
0