結果
問題 | No.1664 Unstable f(n) |
ユーザー | Jetman |
提出日時 | 2021-09-03 22:27:14 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,110 bytes |
コンパイル時間 | 2,461 ms |
コンパイル使用メモリ | 78,168 KB |
実行使用メモリ | 58,968 KB |
最終ジャッジ日時 | 2024-05-09 05:01:43 |
合計ジャッジ時間 | 6,876 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
42,656 KB |
testcase_01 | AC | 57 ms
37,216 KB |
testcase_02 | AC | 57 ms
37,224 KB |
testcase_03 | AC | 57 ms
37,284 KB |
testcase_04 | AC | 58 ms
36,840 KB |
testcase_05 | AC | 56 ms
37,080 KB |
testcase_06 | AC | 59 ms
37,272 KB |
testcase_07 | AC | 58 ms
37,120 KB |
testcase_08 | AC | 57 ms
37,144 KB |
testcase_09 | AC | 58 ms
37,304 KB |
testcase_10 | AC | 60 ms
36,844 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; FastReader in = new FastReader(inputStream); PrintWriter out = new PrintWriter(outputStream); No1664UnstableFn solver = new No1664UnstableFn(); solver.solve(1, in, out); out.close(); } static class No1664UnstableFn { public void solve(int testNumber, FastReader in, PrintWriter out) { long n = in.nextLong(); long ans = n; long tmp = (long) Math.sqrt(n); ans = Math.min(ans, tmp + 2 + (n - tmp * tmp)); for (long i = 2; i * i * i <= n; i++) { tmp = i * i * i; long num = 3; do { ans = Math.min(ans, i + num + (n - tmp)); tmp *= i; } while (tmp <= n); } out.println(ans); } } static class FastReader { BufferedReader br; StringTokenizer st = new StringTokenizer(""); public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } public String next() { while (st == null || (!st.hasMoreElements())) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } public long nextLong() { return Long.parseLong(next()); } } }