結果
| 問題 |
No.1664 Unstable f(n)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-03 23:15:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 716 bytes |
| コンパイル時間 | 640 ms |
| コンパイル使用メモリ | 69,088 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-15 17:40:04 |
| 合計ジャッジ時間 | 1,884 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 7 |
ソースコード
#include <iostream>
#include <cmath>
using namespace std;
long long kpow(long long x, long long n)
{
if (n == 0)
return 1;
long long t = 1;
while (n)
{
if (n & 1)
t *= x;
n >>= 1;
x *= x;
}
return t;
}
int main()
{
long long n;
scanf("%lld", &n);
if(n==1)
{
puts("1");
return 0;
}
long long ans = n;
long long i = 0, j = 0, k = n;
long long lst = n;
while (1)
{
j++;
i = pow(n*1.0, 1.0 / j);
k = n - kpow(i, j);
ans = min(ans, i + j + k);
if (i == 1)
{
printf("%lld\n", ans);
break;
}
}
return 0;
}