結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー cielciel
提出日時 2015-12-14 05:42:53
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 11,488 KB
実行使用メモリ 15,400 KB
最終ジャッジ日時 2023-10-13 16:13:13
合計ジャッジ時間 5,995 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,116 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 82 ms
15,104 KB
testcase_06 WA -
testcase_07 AC 83 ms
15,288 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 82 ms
15,272 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 81 ms
15,116 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:29: warning: statement not reached
Main.rb:29: warning: assigned but unused variable - k2
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
		g0,g1,g2=egcd(2*a,2*b)
		z=b*b-a*a
		w=z2*x*a+z1*x*b-y
		return -w%z.gcd(g0)==0

		_,k1,k2=egcd(z,g0)
		n=w*k1%g0+g0*0
		m=(z*n+w)/g0
		f=0
		_d=g1*m+2*b*f
		_b=g2*m-2*a*f
		_a=z1*x+b*n-_b
		_c=z2*x-a*n-_d
		p [_a,_b,_c,_d,(_a+_b)*a+(_c+_d)*b,(_c-_d)*a+(_a-_b)*b]
	}
end
0