結果

問題 No.2420 Simple Problem
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-09 12:57:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 1,117 bytes
コンパイル時間 2,449 ms
コンパイル使用メモリ 109,536 KB
実行使用メモリ 37,632 KB
最終ジャッジ日時 2023-10-09 12:58:02
合計ジャッジ時間 18,683 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,776 KB
testcase_01 AC 222 ms
30,804 KB
testcase_02 AC 63 ms
21,908 KB
testcase_03 AC 118 ms
24,732 KB
testcase_04 AC 365 ms
31,940 KB
testcase_05 AC 276 ms
27,796 KB
testcase_06 AC 439 ms
35,568 KB
testcase_07 AC 434 ms
33,548 KB
testcase_08 AC 468 ms
31,448 KB
testcase_09 AC 448 ms
35,636 KB
testcase_10 AC 466 ms
35,564 KB
testcase_11 AC 452 ms
33,572 KB
testcase_12 AC 447 ms
35,704 KB
testcase_13 AC 438 ms
33,512 KB
testcase_14 AC 436 ms
35,692 KB
testcase_15 AC 474 ms
33,532 KB
testcase_16 AC 459 ms
33,584 KB
testcase_17 AC 473 ms
35,528 KB
testcase_18 AC 444 ms
35,660 KB
testcase_19 AC 444 ms
31,432 KB
testcase_20 AC 463 ms
33,624 KB
testcase_21 AC 440 ms
37,632 KB
testcase_22 AC 473 ms
35,580 KB
testcase_23 AC 449 ms
35,540 KB
testcase_24 AC 453 ms
33,636 KB
testcase_25 AC 444 ms
33,536 KB
testcase_26 AC 61 ms
23,900 KB
testcase_27 AC 375 ms
29,888 KB
testcase_28 AC 387 ms
33,860 KB
testcase_29 AC 370 ms
33,932 KB
testcase_30 AC 369 ms
33,848 KB
testcase_31 AC 389 ms
31,820 KB
testcase_32 AC 60 ms
21,800 KB
testcase_33 AC 214 ms
28,800 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new ulong[t];
        for (var u = 0; u < t; ++u)
        {
            var c = NList;
            var (a, b) = (c[0], c[1]);
            ans[u] = Problem((ulong)a, (ulong)b);
        }
        WriteLine(string.Join("\n", ans));
    }
    static ulong Problem(ulong a, ulong b)
    {
        checked {
            var ok = (ulong)((Math.Sqrt(a) + Math.Sqrt(b)) * 1.1 + 1);
            var ng = (ulong)0;
            while (ok - ng > 1)
            {
                var mid = (ok + ng) / 2;
                if (mid * mid < a + b) ng = mid;
                else if ((mid * mid - a - b) * (mid * mid - a - b) > 4 * a * b) ok = mid;
                else ng = mid;
            }
            return ok;
        }
    }
}
0