結果

問題 No.550 夏休みの思い出(1)
ユーザー tentententen
提出日時 2023-06-12 14:29:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 2,761 bytes
コンパイル時間 3,216 ms
コンパイル使用メモリ 94,160 KB
実行使用メモリ 53,252 KB
最終ジャッジ日時 2023-09-02 09:30:34
合計ジャッジ時間 9,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
51,076 KB
testcase_01 AC 81 ms
51,552 KB
testcase_02 AC 81 ms
51,396 KB
testcase_03 AC 82 ms
51,432 KB
testcase_04 AC 83 ms
51,544 KB
testcase_05 AC 82 ms
51,764 KB
testcase_06 AC 82 ms
51,628 KB
testcase_07 AC 82 ms
51,444 KB
testcase_08 AC 83 ms
51,400 KB
testcase_09 AC 61 ms
50,988 KB
testcase_10 AC 60 ms
50,916 KB
testcase_11 AC 61 ms
50,948 KB
testcase_12 AC 60 ms
50,896 KB
testcase_13 AC 59 ms
50,912 KB
testcase_14 AC 60 ms
51,184 KB
testcase_15 AC 58 ms
50,896 KB
testcase_16 AC 59 ms
50,852 KB
testcase_17 AC 59 ms
50,944 KB
testcase_18 AC 60 ms
50,852 KB
testcase_19 AC 60 ms
50,912 KB
testcase_20 AC 60 ms
50,940 KB
testcase_21 AC 60 ms
50,944 KB
testcase_22 AC 80 ms
50,916 KB
testcase_23 AC 71 ms
51,608 KB
testcase_24 AC 75 ms
52,932 KB
testcase_25 AC 77 ms
53,008 KB
testcase_26 AC 75 ms
53,236 KB
testcase_27 AC 73 ms
51,580 KB
testcase_28 AC 76 ms
53,252 KB
testcase_29 AC 67 ms
49,992 KB
testcase_30 AC 79 ms
52,936 KB
testcase_31 AC 59 ms
51,020 KB
testcase_32 AC 59 ms
51,072 KB
testcase_33 AC 60 ms
50,916 KB
testcase_34 AC 60 ms
50,892 KB
testcase_35 AC 61 ms
51,040 KB
testcase_36 AC 60 ms
50,732 KB
testcase_37 AC 61 ms
51,240 KB
testcase_38 AC 61 ms
50,892 KB
testcase_39 AC 60 ms
50,936 KB
testcase_40 AC 64 ms
51,072 KB
testcase_41 AC 64 ms
50,896 KB
testcase_42 AC 64 ms
50,980 KB
testcase_43 AC 62 ms
50,880 KB
testcase_44 AC 62 ms
50,796 KB
testcase_45 AC 61 ms
50,888 KB
testcase_46 AC 62 ms
50,988 KB
testcase_47 AC 60 ms
50,900 KB
testcase_48 AC 60 ms
51,236 KB
testcase_49 AC 60 ms
50,988 KB
testcase_50 AC 60 ms
50,832 KB
testcase_51 AC 61 ms
50,828 KB
testcase_52 AC 63 ms
50,936 KB
testcase_53 AC 63 ms
51,072 KB
testcase_54 AC 63 ms
50,836 KB
testcase_55 AC 62 ms
50,844 KB
testcase_56 AC 62 ms
50,844 KB
testcase_57 AC 63 ms
50,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
    
}
0