結果
問題 | No.1664 Unstable f(n) |
ユーザー | Jetman |
提出日時 | 2021-09-03 23:04:51 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,189 bytes |
コンパイル時間 | 2,385 ms |
コンパイル使用メモリ | 84,424 KB |
実行使用メモリ | 51,132 KB |
最終ジャッジ日時 | 2024-05-09 06:33:47 |
合計ジャッジ時間 | 6,073 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
36,824 KB |
testcase_01 | AC | 44 ms
37,284 KB |
testcase_02 | AC | 43 ms
36,824 KB |
testcase_03 | AC | 42 ms
37,368 KB |
testcase_04 | AC | 42 ms
37,256 KB |
testcase_05 | AC | 44 ms
37,240 KB |
testcase_06 | AC | 46 ms
37,116 KB |
testcase_07 | AC | 44 ms
37,360 KB |
testcase_08 | AC | 42 ms
36,964 KB |
testcase_09 | AC | 43 ms
37,416 KB |
testcase_10 | AC | 42 ms
37,384 KB |
testcase_11 | AC | 56 ms
37,616 KB |
testcase_12 | AC | 109 ms
38,220 KB |
testcase_13 | AC | 105 ms
37,980 KB |
testcase_14 | AC | 98 ms
38,192 KB |
testcase_15 | AC | 67 ms
38,232 KB |
testcase_16 | AC | 89 ms
38,196 KB |
testcase_17 | AC | 117 ms
37,972 KB |
testcase_18 | AC | 122 ms
38,120 KB |
testcase_19 | AC | 130 ms
38,156 KB |
testcase_20 | AC | 101 ms
37,952 KB |
testcase_21 | AC | 44 ms
37,116 KB |
testcase_22 | AC | 43 ms
37,368 KB |
testcase_23 | AC | 43 ms
37,196 KB |
testcase_24 | AC | 43 ms
37,416 KB |
testcase_25 | AC | 43 ms
37,120 KB |
testcase_26 | AC | 41 ms
37,316 KB |
testcase_27 | AC | 42 ms
37,416 KB |
testcase_28 | AC | 44 ms
37,336 KB |
testcase_29 | AC | 47 ms
37,416 KB |
testcase_30 | AC | 44 ms
36,784 KB |
testcase_31 | AC | 43 ms
36,824 KB |
testcase_32 | AC | 46 ms
37,360 KB |
testcase_33 | AC | 43 ms
37,300 KB |
testcase_34 | AC | 45 ms
37,076 KB |
testcase_35 | WA | - |
testcase_36 | AC | 43 ms
37,276 KB |
testcase_37 | AC | 64 ms
38,092 KB |
testcase_38 | AC | 43 ms
37,076 KB |
testcase_39 | AC | 45 ms
37,240 KB |
testcase_40 | AC | 54 ms
37,352 KB |
ソースコード
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) + 0.0000000001); ans = Math.min(ans, tmp + 2 + (n - tmp * tmp)); for (long i = 2; i * i * i <= n; i++) { long k = (long) ((Math.log(n) / Math.log(i)) + 0.0000000001); if (Math.pow(i, k) > n) { out.println(i + " " + k); } ans = Math.min(ans, i + k + (n - (long) (Math.pow(i, k) + 0.0000000001))); } 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()); } } }