結果

問題 No.2420 Simple Problem
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-09 12:31:26
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,930 ms / 2,000 ms
コード長 1,521 bytes
コンパイル時間 1,112 ms
コンパイル使用メモリ 110,516 KB
実行使用メモリ 36,868 KB
最終ジャッジ日時 2023-12-19 11:13:06
合計ジャッジ時間 58,559 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
25,696 KB
testcase_01 AC 803 ms
32,224 KB
testcase_02 AC 39 ms
25,696 KB
testcase_03 AC 313 ms
30,180 KB
testcase_04 AC 1,534 ms
35,332 KB
testcase_05 AC 986 ms
33,052 KB
testcase_06 AC 1,909 ms
36,868 KB
testcase_07 AC 1,906 ms
36,868 KB
testcase_08 AC 1,907 ms
36,868 KB
testcase_09 AC 1,916 ms
36,868 KB
testcase_10 AC 1,908 ms
36,868 KB
testcase_11 AC 1,916 ms
36,868 KB
testcase_12 AC 1,917 ms
36,868 KB
testcase_13 AC 1,912 ms
36,868 KB
testcase_14 AC 1,913 ms
36,868 KB
testcase_15 AC 1,909 ms
36,868 KB
testcase_16 AC 1,917 ms
36,868 KB
testcase_17 AC 1,911 ms
36,868 KB
testcase_18 AC 1,930 ms
36,868 KB
testcase_19 AC 1,915 ms
36,868 KB
testcase_20 AC 1,917 ms
36,868 KB
testcase_21 AC 1,918 ms
36,868 KB
testcase_22 AC 1,916 ms
36,868 KB
testcase_23 AC 1,913 ms
36,868 KB
testcase_24 AC 1,916 ms
36,868 KB
testcase_25 AC 1,911 ms
36,868 KB
testcase_26 AC 32 ms
25,696 KB
testcase_27 AC 1,481 ms
35,204 KB
testcase_28 AC 1,486 ms
35,204 KB
testcase_29 AC 1,482 ms
35,204 KB
testcase_30 AC 1,480 ms
35,204 KB
testcase_31 AC 1,480 ms
35,204 KB
testcase_32 AC 31 ms
25,696 KB
testcase_33 AC 782 ms
32,076 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();
        // 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;
        // }
    }
}
0