結果

問題 No.356 円周上を回る3つの動点の一致
ユーザー 37zigen
提出日時 2016-04-01 23:43:14
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 795 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 79,388 KB
実行使用メモリ 56,996 KB
最終ジャッジ日時 2024-10-02 09:55:25
合計ジャッジ時間 11,917 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder356;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int t1=sc.nextInt();
		int t2=sc.nextInt();
		int t3=sc.nextInt();
		int lcm=LCM(t1,t2,t3);
		int[] d={lcm/t1,lcm/t2,lcm/t3};
		Arrays.sort(d);
		for(int i=d[1]-1;i>=1;i--){
			if(d[0]%i==d[1]%i&&d[1]%i==d[2]%i){
				System.out.println(lcm+"/"+i);
				return;
			}
		}
	}
	//最小公倍数
	public static int LCM(int t1,int t2,int t3){
		return LCM(LCM(t1,t2),t3);
	}
	public static int LCM(int t1,int t2){
		int a=GCD(t1,t2);
		int tt1=t1/a;
		int tt2=t2/a;
		return tt1*tt2*a;
	}
	public static int GCD(int t1,int t2){
		if(t1<t2){
			int d=t2;
			t2=t1;
			t1=d;
		}
		if(t2==0)return t1;
		return GCD(t2,t1%t2);
	}
}
0