結果
| 問題 |
No.2420 Simple Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-09 12:31:26 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 1,958 ms / 2,000 ms |
| コード長 | 1,521 bytes |
| コンパイル時間 | 2,522 ms |
| コンパイル使用メモリ | 112,292 KB |
| 実行使用メモリ | 38,888 KB |
| 最終ジャッジ日時 | 2024-09-27 08:47:38 |
| 合計ジャッジ時間 | 60,290 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 33 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
static int NN => int.Parse(ReadLine());
static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
public static void Main()
{
Solve();
// Test();
}
static void Test()
{
var r = new Random();
var count = 0;
var now = DateTime.Now;
while (true)
{
var a = r.Next(1_000_000_000) + 1;
var b = r.Next(1_000_000_000) + 1;
var s = Problem(a, b);
++count;
if (count == 200000) break;
}
WriteLine((DateTime.Now - now).TotalSeconds);
}
static void Solve()
{
var t = NN;
var ans = new long[t];
for (var u = 0; u < t; ++u)
{
var c = NList;
var (a, b) = (c[0], c[1]);
ans[u] = (long)Problem(a, b);
}
WriteLine(string.Join("\n", ans));
}
static decimal Problem(long a, long b)
{
// checked {
var ok = ((decimal)Math.Sqrt(a) + (decimal)Math.Sqrt(b)) * 2;
var ng = decimal.Zero;
while (ok - ng > 1)
{
var mid = decimal.Floor((ok + ng) / 2);
if ((mid * mid - a - b) * (mid * mid - a - b) > 4 * a * b) ok = mid;
else ng = mid;
}
return ok;
// }
}
}