結果
問題 | No.1664 Unstable f(n) |
ユーザー | Jetman |
提出日時 | 2021-09-03 22:27:14 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,110 bytes |
コンパイル時間 | 2,206 ms |
コンパイル使用メモリ | 77,388 KB |
実行使用メモリ | 102,720 KB |
最終ジャッジ日時 | 2024-12-15 14:39:10 |
合計ジャッジ時間 | 44,640 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
57,208 KB |
testcase_01 | AC | 58 ms
102,456 KB |
testcase_02 | AC | 56 ms
56,996 KB |
testcase_03 | AC | 56 ms
102,468 KB |
testcase_04 | AC | 56 ms
57,000 KB |
testcase_05 | AC | 56 ms
102,452 KB |
testcase_06 | AC | 55 ms
57,360 KB |
testcase_07 | AC | 55 ms
102,652 KB |
testcase_08 | AC | 56 ms
57,156 KB |
testcase_09 | AC | 56 ms
102,720 KB |
testcase_10 | AC | 56 ms
57,384 KB |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | AC | 57 ms
102,616 KB |
testcase_22 | AC | 57 ms
57,092 KB |
testcase_23 | AC | 58 ms
102,212 KB |
testcase_24 | AC | 58 ms
57,364 KB |
testcase_25 | AC | 56 ms
50,404 KB |
testcase_26 | AC | 57 ms
50,548 KB |
testcase_27 | AC | 57 ms
50,504 KB |
testcase_28 | AC | 56 ms
50,348 KB |
testcase_29 | AC | 57 ms
50,460 KB |
testcase_30 | AC | 59 ms
50,404 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | TLE | - |
testcase_36 | WA | - |
testcase_37 | TLE | - |
testcase_38 | AC | 57 ms
50,564 KB |
testcase_39 | WA | - |
testcase_40 | TLE | - |
ソースコード
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()); } } }