結果
| 問題 |
No.550 夏休みの思い出(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-29 00:11:10 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 127 ms / 2,000 ms |
| コード長 | 749 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-10-10 07:01:12 |
| 合計ジャッジ時間 | 7,268 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
コンパイルメッセージ
Syntax OK
ソースコード
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 my_nice_function(x)
(4.0/3.0*(@b-@a*@a)*x+8.0/3.0*(@c-@a*@b))/(3.0*x*x+2.0*x*@a+@b)+(3.0*x+@a)/9.0
end
def newton(x)
x = (x).to_f
200.times{
x = x-calc(x)/divc(x)# my_nice_function(x)#
}
x.round
end
chance = (-20..20).to_a
chance << (-1e9.to_i)
chance << (1e9.to_i)
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
x0 = chance.pop unless chance.empty?
z = newton(x0)
next unless calc(z) == 0
li << z
li.sort!.uniq!
end
puts li*" "