結果

問題 No.550 夏休みの思い出(1)
ユーザー cielciel
提出日時 2017-07-30 04:38:34
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 1,485 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 17,028 KB
最終ジャッジ日時 2023-08-01 04:48:15
合計ジャッジ時間 7,585 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
15,280 KB
testcase_01 WA -
testcase_02 AC 97 ms
16,376 KB
testcase_03 AC 96 ms
16,316 KB
testcase_04 WA -
testcase_05 AC 98 ms
16,256 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 98 ms
16,268 KB
testcase_09 WA -
testcase_10 AC 85 ms
15,288 KB
testcase_11 AC 86 ms
15,288 KB
testcase_12 WA -
testcase_13 AC 82 ms
15,124 KB
testcase_14 AC 87 ms
15,192 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 85 ms
15,316 KB
testcase_18 AC 84 ms
15,140 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 87 ms
15,136 KB
testcase_22 AC 88 ms
15,176 KB
testcase_23 AC 84 ms
15,264 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 84 ms
15,172 KB
testcase_27 AC 83 ms
15,204 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 85 ms
15,212 KB
testcase_31 AC 85 ms
15,092 KB
testcase_32 AC 86 ms
15,048 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 85 ms
15,288 KB
testcase_36 AC 85 ms
15,296 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 85 ms
15,136 KB
testcase_40 AC 86 ms
15,280 KB
testcase_41 AC 84 ms
15,084 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 82 ms
15,288 KB
testcase_45 AC 83 ms
15,308 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 82 ms
15,204 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 84 ms
15,204 KB
testcase_53 AC 84 ms
15,308 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 83 ms
15,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/usr/bin/ruby
class Integer
	def pow_binary_mod(y,m)
		x = self
		z = 1
		while y!=0
			z=z*x%m if y&1!=0
			x=x*x%m
			y>>=1
		end
		z
	end
	def miller_rabin
		n=self.abs #todo#
		return true if n==2
		return false if n==1||n%2==0
		d=n-1
		s=0
		while d%2==0
			d/=2
			s+=1
		end
		a=1
		5.times{|_| #todo#
			a+=1
			a+=1 while a.gcd(n)!=1 #todo#
			r=a.pow_binary_mod(d,n)
			next if r==1||r==n-1
			if s.times.none?{|j|
				r=r.pow_binary_mod(2,n)
				r==n-1
			}
				return false
			end
		}
		return true
	end
	def rho3
		#get one divisor
		def rhonext(x,n,seed) (x*x+seed)%n end
		n=self
		#raise if n<2
		[1,3,5].each{|seed| #todo#
			x=y=1 #todo#
			q=i=1
			loop{
				if i==q
					y=x
					q*=2
				end
				x=rhonext(x,n,seed)
				d=(x-y).abs.gcd(n)
				if d>1
					break if d==n
					return d
				end
				i+=1
			}
		}
		nil
	end
	def rho2
		#get all divisors
		n=self
		#raise if n<2
		r=[]
		while n>1
			if n.miller_rabin
				return r+[n]
			else
				x=n.rho3
				if !x
					STDERR.puts 'suspicious: %d'%n
					return r+[n]
				end
				r+=x.rho2
				n/=x
			end
		end
		r
	end
	def rho
		n=self
		r=[]
		if n<0
			r<<-1
			n=-n
		end
		return r if n<2
		[2].each{|e| #todo#
			while n%e==0
				n/=e
				r<<e
			end
		}
		return r if n==1
		r+n.rho2
	end
end

A,B,C=gets.split.map &:to_i
K=C==0?B: C
h=Hash.new 0
[-1,*K.rho].each{|e|h[e]+=1}
c=h.map{|n,p|(0..p).map{|i|n**i}}
puts [0,*c.shift.product(*c).map{|_|_.reduce(1,:*)}].select{|x|x**3+A*x**2+B*x+C==0}.sort*' '
0