結果
問題 |
No.751 Frac #2
|
ユーザー |
![]() |
提出日時 | 2018-11-14 18:02:37 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 833 bytes |
コンパイル時間 | 2,514 ms |
コンパイル使用メモリ | 85,456 KB |
実行使用メモリ | 56,956 KB |
最終ジャッジ日時 | 2024-12-24 13:45:37 |
合計ジャッジ時間 | 10,557 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 28 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n1 = 0; int a1 = 1; int a2 = 1; int n2 = 0; int b1 = 1; int b2 = 1; n1 = sc.nextInt(); a1 = sc.nextInt(); for(int i=1;i<n1;i++) { a2 *= sc.nextInt(); } n2 = sc.nextInt(); b1 = sc.nextInt(); for(int i=1;i<n2;i++) { b2 *= sc.nextInt(); } a1 *= b2; a2 *= b1; int gcf = calculateGcf(a1, a2); a1 /= gcf; a2 /= gcf; System.out.println(a1+" "+a2); } static int calculateGcf(int m, int n) { int s = 0; while(m % n != 0) { s = m; m = n; n = s % n; } return n; } }