結果
| 問題 |
No.2420 Simple Problem
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2023-08-19 16:52:17 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 1,346 ms / 2,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 4,868 ms |
| コンパイル使用メモリ | 103,296 KB |
| 実行使用メモリ | 21,888 KB |
| 最終ジャッジ日時 | 2024-09-27 05:43:20 |
| 合計ジャッジ時間 | 44,491 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 static System.Math;
using System;
public class Hello
{
static void Main()
{
var T = int.Parse(Console.ReadLine().Trim());
while (T-- > 0)
{
string[] line = Console.ReadLine().Trim().Split(' ');
var a = long.Parse(line[0]);
var b = long.Parse(line[1]);
getAns(a, b);
}
}
static bool check(long a, long b, long t)
{
var w = t * t - a - b;
return 4 * a * b < w * w;
}
static void getAns(long a, long b)
{
var ok = (long)Sqrt(a) + (long)Sqrt(b) + 10;
var ng = (long)Sqrt(a) + (long)Sqrt(b) - 1;
while (ok - ng > 1)
{
var mid = ng + (ok - ng) / 2L;
if (check(a, b, mid)) ok = mid;
else ng = mid;
}
Console.WriteLine(ok);
}
}
bluemegane