結果
| 問題 | No.955 ax^2+bx+c=0 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-24 23:35:55 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 2,000 ms |
| コード長 | 2,481 bytes |
| 記録 | |
| コンパイル時間 | 8,671 ms |
| コンパイル使用メモリ | 168,244 KB |
| 実行使用メモリ | 190,168 KB |
| 最終ジャッジ日時 | 2025-12-24 23:37:02 |
| 合計ジャッジ時間 | 17,543 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 122 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (145 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.Intrinsics.Arm;
class Program
{
static int NN => int.Parse(ReadLine());
static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
public static void Main()
{
Solve();
}
static void Solve()
{
var p = NList;
var (a, b, c) = (p[0], p[1], p[2]);
if (a == 0)
{
if (b == 0)
{
if (c == 0) WriteLine(-1);
else WriteLine(0);
}
else
{
WriteLine(1);
WriteLine(- (double)c / b);
}
}
else
{
var root = (long)b * b - 4L * a * c;
if (root < 0)
{
WriteLine(0);
}
else if (root == 0)
{
WriteLine(1);
WriteLine(- b / 2.0 / a);
}
else
{
var d = new System.Numerics.BigInteger(1_000_000_000_000);
var first = -d * b;
var second = d * d * root;
var ng = System.Numerics.BigInteger.Zero;
var ok = d * root;
while (ok - ng > 1)
{
var mid = (ok + ng) / 2;
if (mid * mid >= second) ok = mid;
else ng = mid;
}
WriteLine(2);
var ans1 = (first - ok) / 2 / a;
var ans2 = (first + ok) / 2 / a;
if (a < 0) (ans1, ans2) = (ans2, ans1);
if (ans1 < 0)
{
ans1 = -ans1;
WriteLine($"-{ans1 / d}.{ans1 % d :000000000000}");
}
else
{
WriteLine($"{ans1 / d}.{ans1 % d :000000000000}");
}
if (ans2 < 0)
{
ans2 = -ans2;
WriteLine($"-{ans2 / d}.{ans2 % d :000000000000}");
}
else
{
WriteLine($"{ans2 / d}.{ans2 % d :000000000000}");
}
}
}
}
}