結果
問題 | No.1664 Unstable f(n) |
ユーザー | Jetman |
提出日時 | 2021-09-03 22:42:08 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,266 bytes |
コンパイル時間 | 2,145 ms |
コンパイル使用メモリ | 77,544 KB |
実行使用メモリ | 53,376 KB |
最終ジャッジ日時 | 2024-05-09 05:40:28 |
合計ジャッジ時間 | 6,074 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,208 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 53 ms
37,264 KB |
testcase_04 | AC | 53 ms
37,184 KB |
testcase_05 | AC | 53 ms
37,164 KB |
testcase_06 | AC | 53 ms
37,248 KB |
testcase_07 | AC | 54 ms
37,548 KB |
testcase_08 | AC | 55 ms
37,440 KB |
testcase_09 | AC | 54 ms
37,440 KB |
testcase_10 | AC | 53 ms
37,432 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 54 ms
37,216 KB |
testcase_22 | AC | 53 ms
37,292 KB |
testcase_23 | AC | 53 ms
37,256 KB |
testcase_24 | AC | 53 ms
37,432 KB |
testcase_25 | AC | 54 ms
36,892 KB |
testcase_26 | AC | 54 ms
37,308 KB |
testcase_27 | AC | 54 ms
37,408 KB |
testcase_28 | AC | 54 ms
36,892 KB |
testcase_29 | AC | 55 ms
37,296 KB |
testcase_30 | AC | 54 ms
37,408 KB |
testcase_31 | AC | 54 ms
37,440 KB |
testcase_32 | WA | - |
testcase_33 | AC | 52 ms
37,304 KB |
testcase_34 | AC | 51 ms
37,440 KB |
testcase_35 | WA | - |
testcase_36 | AC | 56 ms
37,004 KB |
testcase_37 | WA | - |
testcase_38 | AC | 54 ms
37,420 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
ソースコード
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.001); 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; long k = (long) ((Math.log(n) / Math.log(i)) + 0.001); ans = Math.min(ans, i + k + (n - (long) (Math.pow(i, k) + 0.001))); // 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()); } } }