結果

問題 No.1664 Unstable f(n)
ユーザー bluemeganebluemegane
提出日時 2021-09-04 10:52:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 1,929 ms
コンパイル使用メモリ 63,180 KB
実行使用メモリ 23,260 KB
最終ジャッジ日時 2023-08-22 17:53:02
合計ジャッジ時間 5,568 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
23,124 KB
testcase_01 AC 56 ms
21,196 KB
testcase_02 AC 55 ms
21,200 KB
testcase_03 AC 55 ms
20,700 KB
testcase_04 AC 55 ms
20,752 KB
testcase_05 AC 55 ms
20,840 KB
testcase_06 AC 57 ms
23,196 KB
testcase_07 AC 56 ms
21,192 KB
testcase_08 AC 55 ms
21,168 KB
testcase_09 AC 56 ms
23,156 KB
testcase_10 AC 55 ms
21,308 KB
testcase_11 AC 57 ms
23,196 KB
testcase_12 AC 55 ms
23,248 KB
testcase_13 AC 56 ms
23,144 KB
testcase_14 AC 55 ms
21,244 KB
testcase_15 AC 58 ms
21,180 KB
testcase_16 AC 55 ms
21,196 KB
testcase_17 AC 55 ms
23,260 KB
testcase_18 AC 55 ms
21,180 KB
testcase_19 AC 55 ms
21,180 KB
testcase_20 AC 56 ms
23,244 KB
testcase_21 AC 56 ms
23,176 KB
testcase_22 AC 55 ms
21,132 KB
testcase_23 AC 56 ms
23,224 KB
testcase_24 AC 56 ms
21,136 KB
testcase_25 AC 57 ms
23,232 KB
testcase_26 AC 57 ms
21,164 KB
testcase_27 AC 55 ms
21,260 KB
testcase_28 AC 55 ms
21,152 KB
testcase_29 AC 54 ms
19,276 KB
testcase_30 AC 56 ms
21,312 KB
testcase_31 AC 56 ms
21,228 KB
testcase_32 AC 56 ms
21,216 KB
testcase_33 AC 56 ms
23,108 KB
testcase_34 AC 57 ms
21,184 KB
testcase_35 AC 55 ms
23,224 KB
testcase_36 AC 56 ms
21,220 KB
testcase_37 AC 55 ms
19,152 KB
testcase_38 AC 55 ms
21,084 KB
testcase_39 AC 55 ms
19,140 KB
testcase_40 AC 55 ms
21,196 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);
        else 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++; }
            if (k >= 0) ans = Min(ans, i + j + k);
        }
        Console.WriteLine(ans);
    }
}
0