結果
問題 | No.356 円周上を回る3つの動点の一致 |
ユーザー |
|
提出日時 | 2016-04-01 23:54:28 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 890 bytes |
コンパイル時間 | 2,626 ms |
コンパイル使用メモリ | 79,384 KB |
実行使用メモリ | 42,636 KB |
最終ジャッジ日時 | 2024-10-02 10:02:06 |
合計ジャッジ時間 | 12,784 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 27 |
ソースコード
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); if(t1==t2&&t2==t3){ System.out.println(0); return; } int[] d={lcm/t1,lcm/t2,lcm/t3}; Arrays.sort(d); for(int i=d[2]-1;i>=1;i--){ if(d[0]%i==d[1]%i&&d[1]%i==d[2]%i){ int aaa=GCD(lcm,i); System.out.println(lcm/aaa+"/"+i/aaa); 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); } }