結果

問題 No.328 きれいな連立方程式
ユーザー GrenacheGrenache
提出日時 2015-12-21 19:56:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 3,118 bytes
コンパイル時間 4,281 ms
コンパイル使用メモリ 79,572 KB
実行使用メモリ 50,496 KB
最終ジャッジ日時 2024-09-18 18:05:51
合計ジャッジ時間 7,199 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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