結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー Grenache
提出日時 2015-06-20 11:57:58
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,024 bytes
コンパイル時間 3,463 ms
コンパイル使用メモリ 84,148 KB
実行使用メモリ 55,384 KB
最終ジャッジ日時 2024-07-07 15:09:00
合計ジャッジ時間 11,828 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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 max = 1;
        max = Math.max(max, gcd(gcd(Math.abs(t2 - t1), Math.abs(t3 - t2)), Math.abs(t1 - t3)));
        max = Math.max(max, gcd(gcd(Math.abs(t2 - t1), Math.abs(t3 + t2)), Math.abs(t1 + t3)));
        max = Math.max(max, gcd(gcd(Math.abs(t3 - t2), Math.abs(t1 + t3)), Math.abs(t2 + t1)));
        max = Math.max(max, gcd(gcd(Math.abs(t1 - t3), Math.abs(t2 + t1)), Math.abs(t3 + t2)));

        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