結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー Grenache
提出日時 2015-06-20 12:21:00
言語 Java
(openjdk 23)
結果
AC  
実行時間 159 ms / 5,000 ms
コード長 1,119 bytes
コンパイル時間 4,062 ms
コンパイル使用メモリ 79,120 KB
実行使用メモリ 42,340 KB
最終ジャッジ日時 2024-07-07 15:09:33
合計ジャッジ時間 10,467 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

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