結果
問題 | No.550 夏休みの思い出(1) |
ユーザー | tenten |
提出日時 | 2023-06-12 14:29:14 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 2,761 bytes |
コンパイル時間 | 2,779 ms |
コンパイル使用メモリ | 91,428 KB |
実行使用メモリ | 38,976 KB |
最終ジャッジ日時 | 2024-06-11 16:17:25 |
合計ジャッジ時間 | 7,476 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
37,932 KB |
testcase_01 | AC | 78 ms
38,544 KB |
testcase_02 | AC | 79 ms
38,540 KB |
testcase_03 | AC | 79 ms
38,644 KB |
testcase_04 | AC | 88 ms
38,804 KB |
testcase_05 | AC | 86 ms
38,552 KB |
testcase_06 | AC | 85 ms
38,528 KB |
testcase_07 | AC | 81 ms
38,752 KB |
testcase_08 | AC | 82 ms
38,800 KB |
testcase_09 | AC | 59 ms
37,904 KB |
testcase_10 | AC | 60 ms
38,240 KB |
testcase_11 | AC | 60 ms
38,388 KB |
testcase_12 | AC | 58 ms
37,756 KB |
testcase_13 | AC | 59 ms
38,420 KB |
testcase_14 | AC | 58 ms
38,420 KB |
testcase_15 | AC | 57 ms
38,288 KB |
testcase_16 | AC | 59 ms
38,404 KB |
testcase_17 | AC | 68 ms
38,420 KB |
testcase_18 | AC | 61 ms
38,284 KB |
testcase_19 | AC | 58 ms
38,200 KB |
testcase_20 | AC | 58 ms
38,264 KB |
testcase_21 | AC | 56 ms
38,124 KB |
testcase_22 | AC | 75 ms
38,656 KB |
testcase_23 | AC | 72 ms
38,536 KB |
testcase_24 | AC | 72 ms
38,752 KB |
testcase_25 | AC | 75 ms
38,688 KB |
testcase_26 | AC | 73 ms
38,404 KB |
testcase_27 | AC | 74 ms
38,324 KB |
testcase_28 | AC | 68 ms
38,796 KB |
testcase_29 | AC | 65 ms
38,524 KB |
testcase_30 | AC | 85 ms
38,976 KB |
testcase_31 | AC | 62 ms
38,284 KB |
testcase_32 | AC | 60 ms
38,060 KB |
testcase_33 | AC | 59 ms
37,872 KB |
testcase_34 | AC | 66 ms
38,164 KB |
testcase_35 | AC | 61 ms
38,120 KB |
testcase_36 | AC | 62 ms
38,096 KB |
testcase_37 | AC | 59 ms
38,324 KB |
testcase_38 | AC | 58 ms
38,344 KB |
testcase_39 | AC | 58 ms
37,932 KB |
testcase_40 | AC | 59 ms
38,192 KB |
testcase_41 | AC | 61 ms
38,336 KB |
testcase_42 | AC | 64 ms
38,044 KB |
testcase_43 | AC | 60 ms
38,052 KB |
testcase_44 | AC | 60 ms
38,272 KB |
testcase_45 | AC | 61 ms
38,272 KB |
testcase_46 | AC | 60 ms
38,172 KB |
testcase_47 | AC | 58 ms
38,164 KB |
testcase_48 | AC | 56 ms
38,380 KB |
testcase_49 | AC | 57 ms
38,164 KB |
testcase_50 | AC | 57 ms
37,724 KB |
testcase_51 | AC | 58 ms
38,048 KB |
testcase_52 | AC | 59 ms
38,196 KB |
testcase_53 | AC | 59 ms
37,896 KB |
testcase_54 | AC | 58 ms
38,024 KB |
testcase_55 | AC | 60 ms
38,344 KB |
testcase_56 | AC | 61 ms
38,000 KB |
testcase_57 | AC | 60 ms
38,164 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); long ans1 = 0; long aa; long bb; if (c == 0) { aa = a; bb = b; } else { long absc = Math.abs(c); for (long i = 1; i * i * i <= absc; i++) { if (absc % i == 0) { if (i * i * i + a * i * i + b * i + c == 0) { ans1 = i; break; } if (-i * i * i + a * i * i - b * i + c == 0) { ans1 = -i; break; } } } aa = a + ans1; bb = -c / ans1; } long absbb = Math.abs(bb); long left = (1 - aa) / 2; long right = Integer.MAX_VALUE / 2; while (right - left > 1) { long m = (left + right) / 2; if (m * m + aa * m + bb <= 0) { left = m; } else { right = m; } } long ans2 = left; long ans3 = -ans2 - aa; long[] ans = new long[]{ans1, ans2, ans3}; Arrays.sort(ans); System.out.println(String.join(" ", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new))); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }