結果

問題 No.550 夏休みの思い出(1)
ユーザー mai(舞葉)
提出日時 2017-07-30 09:49:57
言語 Ruby
(2.4.1)
結果
AC  
実行時間 89 ms
コード長 539 Byte
コンパイル時間 27 ms
使用メモリ 3960 KB

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
99_challenge01.txt AC 59 ms
3940 KB
manual_a01.txt AC 41 ms
3932 KB
manual_a02.txt AC 25 ms
3936 KB
manual_a03.txt AC 23 ms
3932 KB
manual_a04.txt AC 37 ms
3936 KB
manual_a05.txt AC 39 ms
3932 KB
manual_a06.txt AC 9 ms
3924 KB
manual_a07.txt AC 31 ms
3936 KB
manual_a08.txt AC 18 ms
3928 KB
manual_b01.txt AC 25 ms
3928 KB
manual_b02.txt AC 12 ms
3928 KB
manual_b03.txt AC 10 ms
3932 KB
manual_b04.txt AC 10 ms
3928 KB
random1_01.txt AC 12 ms
3932 KB
random1_02.txt AC 11 ms
3932 KB
random1_03.txt AC 9 ms
3932 KB
random1_04.txt AC 12 ms
3932 KB
random1_05.txt AC 11 ms
3940 KB
random1_06.txt AC 10 ms
3940 KB
random1_07.txt AC 12 ms
3924 KB
random1_08.txt AC 8 ms
3936 KB
random1_09.txt AC 19 ms
3960 KB
random2_01.txt AC 25 ms
3928 KB
random2_02.txt AC 89 ms
3928 KB
random2_03.txt AC 89 ms
3932 KB
random2_04.txt AC 15 ms
3932 KB
random2_05.txt AC 28 ms
3928 KB
random2_06.txt AC 44 ms
3928 KB
random2_07.txt AC 20 ms
3932 KB
random2_08.txt AC 11 ms
3928 KB
random2_09.txt AC 17 ms
3936 KB
random3_01.txt AC 28 ms
3932 KB
random3_02.txt AC 23 ms
3932 KB
random3_03.txt AC 28 ms
3944 KB
random3_04.txt AC 25 ms
3936 KB
random3_05.txt AC 9 ms
3924 KB
random3_06.txt AC 13 ms
3932 KB
random3_07.txt AC 12 ms
3936 KB
random3_08.txt AC 14 ms
3940 KB
random3_09.txt AC 14 ms
3936 KB
random4_01.txt AC 22 ms
3932 KB
random4_02.txt AC 17 ms
3928 KB
random4_03.txt AC 22 ms
3932 KB
random4_04.txt AC 13 ms
3936 KB
random4_05.txt AC 11 ms
3932 KB
random4_06.txt AC 10 ms
3932 KB
random4_07.txt AC 56 ms
3936 KB
random4_08.txt AC 13 ms
3928 KB
random4_09.txt AC 14 ms
3928 KB
sample01.txt AC 28 ms
3956 KB
sample02.txt AC 12 ms
3920 KB
sample03.txt AC 19 ms
3928 KB
z_mean01.txt AC 15 ms
3932 KB
z_mean02.txt AC 17 ms
3920 KB
z_mean03.txt AC 10 ms
3932 KB
z_mean04.txt AC 10 ms
3928 KB
z_mean05.txt AC 20 ms
3928 KB
z_mean06.txt AC 20 ms
3928 KB
テストケース一括ダウンロード

ソースコード

diff #
def ascan; gets.split.map(&:to_i); end
def scan; gets.to_i; end

aa,bb,cc = ascan

@a=aa
@b=bb
@c=cc
def calc(x)
    x*x*x+@a*x*x+@b*x+@c
end

def divc(x)
    3*x*x+2*@a*x+@b
end

def newton(x)
    x = (x).to_f
    200.times{
        return 0 if divc(x) == 0
        x = x-calc(x)/divc(x)
    }
    x.round
end

li = []
while li.size<3
    x0 = rand((-1e9.to_i)..(1e9.to_i))
    x0 = rand((li[0]+1)...(li[1])) if li.size == 2 && rand(50) == 0
    z = newton(x0)
    next unless calc(z) == 0
    li << z
    li.sort!.uniq!
end
puts li*" "

0