結果
問題 |
No.1664 Unstable f(n)
|
ユーザー |
|
提出日時 | 2021-09-04 00:26:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 526 bytes |
コンパイル時間 | 1,442 ms |
コンパイル使用メモリ | 166,532 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-15 20:15:27 |
合計ジャッジ時間 | 18,593 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 TLE * 3 |
コンパイルメッセージ
main.cpp:3:18: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow] 3 | const int maxn = 1e18; | ^~~~
ソースコード
#include <bits/stdc++.h> typedef long long ll; const int maxn = 1e18; ll qmi(ll a, ll k) { ll res = 1; while (k) { if (k & 1) res = (ll)res * a; k >>= 1; a = (ll)a * a; }return res; } int main() { ll n; scanf("%lld", &n); if (n <= 4) {std::cout << n << "\n"; return 0;} ll ans = 1e18; for (ll j = 2; j <= 60; j ++) { ll i = qmi(n, 1.0 / j); while (qmi(i + 1, j) <= n) i ++; ll k = n - qmi(i, j); ans = std::min(ans, i + j + k); } std::cout << ans << "\n"; return 0; }