結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー GrenacheGrenache
提出日時 2015-06-19 23:49:27
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,248 bytes
コンパイル時間 3,959 ms
コンパイル使用メモリ 80,328 KB
実行使用メモリ 58,492 KB
最終ジャッジ日時 2023-09-21 10:22:42
合計ジャッジ時間 39,845 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 721 ms
56,896 KB
testcase_01 AC 143 ms
55,576 KB
testcase_02 AC 158 ms
56,940 KB
testcase_03 AC 156 ms
58,492 KB
testcase_04 AC 145 ms
56,252 KB
testcase_05 AC 156 ms
55,804 KB
testcase_06 AC 146 ms
55,576 KB
testcase_07 AC 1,780 ms
56,208 KB
testcase_08 AC 3,408 ms
55,876 KB
testcase_09 WA -
testcase_10 AC 165 ms
56,820 KB
testcase_11 WA -
testcase_12 AC 371 ms
56,016 KB
testcase_13 AC 144 ms
55,884 KB
testcase_14 WA -
testcase_15 AC 168 ms
56,452 KB
testcase_16 AC 204 ms
55,604 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 539 ms
56,024 KB
testcase_21 AC 491 ms
56,756 KB
testcase_22 AC 2,261 ms
57,072 KB
testcase_23 AC 2,279 ms
56,704 KB
testcase_24 AC 2,418 ms
56,708 KB
testcase_25 AC 455 ms
55,876 KB
testcase_26 AC 203 ms
55,948 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1,633 ms
56,732 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 171 ms
56,756 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 159 ms
56,888 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

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));

        t1 = lcm / t1;
        t2 = lcm / t2;
        t3 = lcm / t3;
        long i;
        long max = Math.max(t1, Math.max(t2, t3));
        for (i = max; i > 0; i--) {
        	long m1 = t1 % i;
        	long m2 = t2 % i;
        	long m3 = t3 % i;
        	if (m1 == m2 || m2 == m3 || m1 == m3) {
        		if (m1 == m2 && m3 + m1 == i) {
        			break;
        		} else if (m2 == m3 && m1 + m2 == i) {
        			break;
        		} else if (m3 == m1 && m2 + m3 == i) {
        			break;
        		}
        	}
        }

        if (i == 0) {
        	System.out.println(lcm + "/" + 1);
        	
        } else {
        	long gcd = gcd(lcm, i);
        	System.out.println(lcm / gcd + "/" + i / 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