結果

問題 No.1664 Unstable f(n)
ユーザー bluemeganebluemegane
提出日時 2021-09-04 10:44:28
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 63,764 KB
実行使用メモリ 23,328 KB
最終ジャッジ日時 2023-08-22 17:41:06
合計ジャッジ時間 4,491 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
21,148 KB
testcase_01 AC 53 ms
21,296 KB
testcase_02 AC 53 ms
19,248 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 52 ms
23,172 KB
testcase_07 AC 52 ms
21,208 KB
testcase_08 AC 53 ms
21,140 KB
testcase_09 AC 52 ms
21,300 KB
testcase_10 AC 54 ms
21,148 KB
testcase_11 AC 53 ms
21,244 KB
testcase_12 AC 53 ms
23,240 KB
testcase_13 AC 54 ms
21,208 KB
testcase_14 AC 53 ms
21,308 KB
testcase_15 AC 54 ms
21,288 KB
testcase_16 AC 53 ms
19,204 KB
testcase_17 AC 53 ms
21,320 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 53 ms
21,128 KB
testcase_21 AC 52 ms
21,244 KB
testcase_22 AC 54 ms
21,128 KB
testcase_23 AC 53 ms
21,220 KB
testcase_24 AC 54 ms
23,300 KB
testcase_25 AC 52 ms
19,076 KB
testcase_26 AC 53 ms
21,300 KB
testcase_27 AC 53 ms
21,292 KB
testcase_28 AC 54 ms
21,156 KB
testcase_29 AC 53 ms
21,080 KB
testcase_30 AC 52 ms
21,164 KB
testcase_31 AC 52 ms
23,212 KB
testcase_32 AC 52 ms
23,272 KB
testcase_33 AC 54 ms
23,328 KB
testcase_34 AC 54 ms
23,292 KB
testcase_35 AC 53 ms
21,268 KB
testcase_36 AC 54 ms
23,320 KB
testcase_37 AC 54 ms
21,180 KB
testcase_38 AC 54 ms
21,160 KB
testcase_39 AC 55 ms
21,172 KB
testcase_40 AC 55 ms
23,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        if (n <= 3) Console.WriteLine(n);
        getAns(n);
    }
    static long Pow(int a, int b, long n)
    {
        var res = 1L;
        for (int i = 0; i < b; i++) res *= a;
        return res <= n ? res : -1;
    }
    static void getAns(long n)
    {
        var ans = n + 1;
        var jmax = (int)(Log10(n) / Log10(2));
        for (int j = 2; j <= jmax; j++)
        {
            var i = (int)Math.Pow(n, 1d / j);
            var a = Pow(i, j, n);
            var a2 = Pow(i + 1, j, n);
            long k;
            if (a2 == -1) k = n - a;
            else { k = n - a2; i++; }
            ans = Min(ans, i + j + k);
        }
        Console.WriteLine(ans);
    }
}
0