結果
| 問題 | No.1664 Unstable f(n) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-04 10:32:31 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 1,132 bytes |
| 記録 | |
| コンパイル時間 | 9,633 ms |
| コンパイル使用メモリ | 168,724 KB |
| 実行使用メモリ | 184,608 KB |
| 最終ジャッジ日時 | 2024-12-17 17:48:57 |
| 合計ジャッジ時間 | 13,041 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (92 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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);
}
}
}