結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー GrenacheGrenache
提出日時 2015-06-20 12:21:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 150 ms / 5,000 ms
コード長 1,119 bytes
コンパイル時間 3,247 ms
コンパイル使用メモリ 75,852 KB
実行使用メモリ 57,132 KB
最終ジャッジ日時 2023-09-21 21:59:36
合計ジャッジ時間 11,582 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
57,000 KB
testcase_01 AC 147 ms
56,720 KB
testcase_02 AC 145 ms
56,592 KB
testcase_03 AC 144 ms
57,084 KB
testcase_04 AC 143 ms
56,556 KB
testcase_05 AC 145 ms
56,628 KB
testcase_06 AC 145 ms
56,852 KB
testcase_07 AC 144 ms
56,700 KB
testcase_08 AC 144 ms
56,592 KB
testcase_09 AC 144 ms
56,840 KB
testcase_10 AC 142 ms
56,652 KB
testcase_11 AC 143 ms
56,472 KB
testcase_12 AC 146 ms
56,788 KB
testcase_13 AC 142 ms
56,928 KB
testcase_14 AC 144 ms
56,860 KB
testcase_15 AC 146 ms
56,624 KB
testcase_16 AC 144 ms
56,716 KB
testcase_17 AC 144 ms
55,100 KB
testcase_18 AC 144 ms
56,620 KB
testcase_19 AC 145 ms
56,856 KB
testcase_20 AC 146 ms
56,576 KB
testcase_21 AC 145 ms
56,872 KB
testcase_22 AC 144 ms
57,072 KB
testcase_23 AC 144 ms
56,724 KB
testcase_24 AC 143 ms
56,720 KB
testcase_25 AC 143 ms
56,992 KB
testcase_26 AC 143 ms
56,552 KB
testcase_27 AC 144 ms
56,700 KB
testcase_28 AC 143 ms
56,816 KB
testcase_29 AC 141 ms
57,056 KB
testcase_30 AC 142 ms
56,576 KB
testcase_31 AC 141 ms
56,624 KB
testcase_32 AC 143 ms
56,844 KB
testcase_33 AC 147 ms
57,132 KB
testcase_34 AC 147 ms
56,848 KB
testcase_35 AC 147 ms
56,844 KB
testcase_36 AC 150 ms
56,940 KB
testcase_37 AC 150 ms
56,752 KB
testcase_38 AC 148 ms
56,912 KB
testcase_39 AC 145 ms
56,728 KB
testcase_40 AC 145 ms
56,976 KB
testcase_41 AC 145 ms
56,840 KB
testcase_42 AC 144 ms
56,780 KB
testcase_43 AC 145 ms
56,548 KB
testcase_44 AC 144 ms
56,760 KB
testcase_45 AC 144 ms
56,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder229 {

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

        long t1 = sc.nextLong();
        long t2 = sc.nextLong();
        long t3 = sc.nextLong();

//        long lcm = lcm(t1, lcm(t2, t3));
        long lcm = t1 * t2 * t3;

        long max = 1;
        max = Math.max(max, gcd(gcd(Math.abs(t2 - t1) * t3, Math.abs(t3 - t2) * t1), Math.abs(t1 - t3) * t2));
        max = Math.max(max, gcd(gcd(Math.abs(t2 - t1) * t3, Math.abs(t3 + t2) * t1), Math.abs(t1 + t3) * t2));
        max = Math.max(max, gcd(gcd(Math.abs(t3 - t2) * t1, Math.abs(t1 + t3) * t2), Math.abs(t2 + t1) * t3));
        max = Math.max(max, gcd(gcd(Math.abs(t1 - t3) * t2, Math.abs(t2 + t1) * t3), Math.abs(t3 + t2) * t1));

        long gcd = gcd(lcm, max);
        System.out.println(lcm / gcd + "/" + max / gcd);
        
        sc.close();
    }

    private static long lcm(long n, long m) {
		return n * m / gcd(n, m);
	}

	private static long gcd(long n, long m) {
		if (m == 0) {
			return n;
		} else {
			return gcd(m, n % m);
		}
	}
}
0