結果

問題 No.1664 Unstable f(n)
ユーザー masayamatumasayamatu
提出日時 2021-09-04 10:32:31
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,132 bytes
コンパイル時間 14,245 ms
コンパイル使用メモリ 146,528 KB
実行使用メモリ 164,276 KB
最終ジャッジ日時 2023-08-22 17:25:59
合計ジャッジ時間 18,247 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
28,524 KB
testcase_01 AC 49 ms
30,436 KB
testcase_02 AC 50 ms
28,528 KB
testcase_03 AC 49 ms
28,048 KB
testcase_04 AC 50 ms
30,004 KB
testcase_05 AC 49 ms
28,204 KB
testcase_06 AC 50 ms
30,460 KB
testcase_07 AC 49 ms
28,320 KB
testcase_08 AC 49 ms
28,200 KB
testcase_09 AC 49 ms
28,256 KB
testcase_10 AC 50 ms
30,384 KB
testcase_11 AC 49 ms
28,432 KB
testcase_12 AC 48 ms
28,496 KB
testcase_13 AC 49 ms
28,416 KB
testcase_14 AC 49 ms
30,480 KB
testcase_15 AC 50 ms
28,492 KB
testcase_16 AC 50 ms
30,324 KB
testcase_17 AC 50 ms
28,380 KB
testcase_18 AC 48 ms
28,284 KB
testcase_19 AC 49 ms
30,376 KB
testcase_20 AC 50 ms
30,236 KB
testcase_21 AC 50 ms
28,464 KB
testcase_22 AC 49 ms
28,476 KB
testcase_23 AC 50 ms
28,568 KB
testcase_24 AC 50 ms
28,588 KB
testcase_25 AC 50 ms
28,380 KB
testcase_26 AC 51 ms
30,608 KB
testcase_27 AC 50 ms
28,456 KB
testcase_28 AC 49 ms
28,228 KB
testcase_29 AC 49 ms
28,272 KB
testcase_30 AC 50 ms
28,268 KB
testcase_31 AC 50 ms
28,460 KB
testcase_32 AC 52 ms
28,360 KB
testcase_33 AC 49 ms
28,488 KB
testcase_34 AC 50 ms
28,548 KB
testcase_35 AC 49 ms
28,296 KB
testcase_36 AC 49 ms
28,308 KB
testcase_37 AC 49 ms
28,244 KB
testcase_38 AC 49 ms
28,312 KB
testcase_39 AC 49 ms
28,552 KB
testcase_40 AC 49 ms
164,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 138 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace yukicoder
{
    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
             long n = long.Parse(Console.ReadLine());
            long ans = longMax;
            if(n < 4)
            {
                Console.WriteLine(n); 
                return;
            } 
            long mpow(long x, long y)
            {
                long ret = 1;
                while (y > 0)
                {
                    if((y & 1) == 1) ret *= x;
                    x *= x;
                    y >>= 1;
                }
                return ret;         
            }
            for(long j = 2; j <= Math.Log2(n); j++)
            {
                long i = (long)Math.Pow(n, 1.0 / j);
                while(Math.Pow(i + 1, j) <= n) i++;
                long k = n - mpow(i, j);
                ans = Math.Min(ans, i + j + k);
            }
            Console.WriteLine(ans);
        }
    }
}
0