結果
問題 |
No.1664 Unstable f(n)
|
ユーザー |
![]() |
提出日時 | 2021-09-04 07:32:21 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 606 bytes |
コンパイル時間 | 2,052 ms |
コンパイル使用メモリ | 108,328 KB |
実行使用メモリ | 18,304 KB |
最終ジャッジ日時 | 2024-12-16 11:06:30 |
合計ジャッジ時間 | 3,035 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 7 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 void getAns(long n) { var ans = n + 1; var imax = (int)(Log10(n) / Log10(2)); for (int j = 2; j <= imax; j++) { var i = (int)Pow(n, 1d / j); var x = 1L; for (int a = 0; a < j; a++) x *= i; var k = n - x; ans = Min(ans, i + j + k); } Console.WriteLine(ans); } }