結果
| 問題 |
No.955 ax^2+bx+c=0
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2020-04-12 23:48:20 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,097 bytes |
| コンパイル時間 | 48 ms |
| コンパイル使用メモリ | 6,940 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 14:24:26 |
| 合計ジャッジ時間 | 2,682 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 114 WA * 8 |
ソースコード
local a, b, c = io.read("*n", "*n", "*n")
if a == 0 then
if b == 0 then
print(c == 0 and -1 or 0)
else
print(1)
print(string.format("%.13f", -c / b))
end
else
local at, bt, ct = 0LL + a, 0LL + b, 0LL + c
local d = bt * bt - 4 * at * ct
if d < 0LL then
print(0)
elseif d == 0LL then
print(1)
print(string.format("%.13f", -b / (2 * a)))
else
if b == 0 then
print(2)
local z = math.sqrt(-c / a)
print(string.format("%.13f", -z))
print(string.format("%.13f", z))
else
local v = -4 * a * c / b / b
if math.abs(v) < 0.00001 then
local z = v / 2 - v * v / 8
local v = 1 + z
local x = b * (-1 - v) / 2 / a
local y = b * z / 2 / a
if y < x then x, y = y, x end
print(2)
print(string.format("%.13f", x))
print(string.format("%.13f", y))
else
print(2)
print(string.format("%.13f", (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a))
print(string.format("%.13f", (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a))
end
end
end
end