結果

問題 No.328 きれいな連立方程式
ユーザー GrenacheGrenache
提出日時 2015-12-21 19:56:48
言語 Java19
(openjdk 21)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 3,118 bytes
コンパイル時間 5,691 ms
コンパイル使用メモリ 79,240 KB
実行使用メモリ 53,888 KB
最終ジャッジ日時 2023-10-18 22:04:04
合計ジャッジ時間 8,632 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
52,772 KB
testcase_01 AC 58 ms
53,868 KB
testcase_02 AC 58 ms
53,876 KB
testcase_03 AC 59 ms
52,756 KB
testcase_04 AC 58 ms
52,756 KB
testcase_05 AC 58 ms
53,884 KB
testcase_06 AC 59 ms
52,912 KB
testcase_07 AC 57 ms
52,740 KB
testcase_08 AC 59 ms
53,872 KB
testcase_09 AC 59 ms
52,936 KB
testcase_10 AC 59 ms
51,824 KB
testcase_11 AC 59 ms
52,776 KB
testcase_12 AC 58 ms
53,812 KB
testcase_13 AC 58 ms
52,772 KB
testcase_14 AC 57 ms
51,980 KB
testcase_15 AC 58 ms
53,868 KB
testcase_16 AC 58 ms
52,968 KB
testcase_17 AC 58 ms
53,864 KB
testcase_18 AC 59 ms
53,880 KB
testcase_19 AC 59 ms
51,820 KB
testcase_20 AC 59 ms
53,872 KB
testcase_21 AC 59 ms
52,952 KB
testcase_22 AC 57 ms
51,984 KB
testcase_23 AC 58 ms
53,872 KB
testcase_24 AC 57 ms
53,864 KB
testcase_25 AC 58 ms
53,884 KB
testcase_26 AC 57 ms
53,864 KB
testcase_27 AC 57 ms
53,888 KB
testcase_28 AC 59 ms
52,772 KB
testcase_29 AC 58 ms
53,864 KB
testcase_30 AC 58 ms
53,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Iterator;


public class Main_yukicoder328 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Printer pr = new Printer(System.out);

        long c1 = sc.nextInt();
        long c2 = sc.nextInt();
        long c3 = sc.nextInt();
        long c4 = sc.nextInt();

        long a3 = c1 * c1 * c3 - c1 * c2 * c2;
        long a2 = c2 * c2 * c2 - c1 * c1 * c4;
        long a1 = - c1 * c3 * c3 - c2 * c2 * c3 + 2L * c1 * c2 * c4;
        long a0 = c2 * c3 * c3 - c2 * c2 * c4;

        BigInteger ba3 = new BigInteger(Long.toString(a3));
        BigInteger ba2 = new BigInteger(Long.toString(a2));
        BigInteger ba1 = new BigInteger(Long.toString(a1));
        BigInteger ba0 = new BigInteger(Long.toString(a0));
//        long d = -4L * a1 * a1 * a1 * a3 + a1 * a1 * a2 * a2 -4L * a0 * a2 * a2 * a2 + 18L * a0 * a1 * a2 * a3 -27L * a0 * a0 * a3 * a3;
        BigInteger tmp1 = new BigInteger(Long.toString(-4));
        tmp1 = tmp1.multiply(ba1).multiply(ba1).multiply(ba1).multiply(ba3);
        BigInteger tmp2 = new BigInteger(Long.toString(1));
        tmp2 = tmp2.multiply(ba1).multiply(ba1).multiply(ba2).multiply(ba2);
        BigInteger tmp3 = new BigInteger(Long.toString(-4));
        tmp3 = tmp3.multiply(ba0).multiply(ba2).multiply(ba2).multiply(ba2);
        BigInteger tmp4 = new BigInteger(Long.toString(18));
        tmp4 = tmp4.multiply(ba0).multiply(ba1).multiply(ba2).multiply(ba3);
        BigInteger tmp5 = new BigInteger(Long.toString(-27));
        tmp5 = tmp5.multiply(ba0).multiply(ba0).multiply(ba3).multiply(ba3);

        BigInteger d = tmp1.add(tmp2).add(tmp3).add(tmp4).add(tmp5);

        if (d.compareTo(BigInteger.ZERO) >= 0) {
        	pr.println("R");
        } else {
        	pr.println("I");
        }

        pr.close();
        sc.close();
    }

    @SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0