結果
| 問題 |
No.751 Frac #2
|
| コンテスト | |
| ユーザー |
x87asdf
|
| 提出日時 | 2018-11-15 17:11:21 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 897 bytes |
| コンパイル時間 | 2,893 ms |
| コンパイル使用メモリ | 81,504 KB |
| 実行使用メモリ | 42,576 KB |
| 最終ジャッジ日時 | 2024-12-24 13:58:32 |
| 合計ジャッジ時間 | 9,999 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | WA * 36 |
ソースコード
import java.util.*;
public class Main {
static Scanner sc;
static long numerator;
static long denominator;
public static void main(String[] args) {
sc = new Scanner(System.in);
numerator = 1;
denominator = 1;
inputNume(sc.nextInt());
inputDeno(sc.nextInt());
long gcf = calculateGcf(numerator, denominator);
numerator /= gcf;
denominator /= gcf;
System.out.println(numerator+" "+denominator);
}
static void inputNume(int l) {
numerator *= sc.nextLong();
for(int i=1;i<l;i++) {
denominator *= sc.nextInt();
}
}
static void inputDeno(int l) {
for(int i=l;i<l;i++) {
if(i % 2 != 0) {
numerator *= sc.nextLong();
} else {
denominator *= sc.nextLong();
}
}
}
static long calculateGcf(long m, long n) {
if(m == 0 || n == 0) {
return 1;
}
long s = 0;
while(m % n != 0) {
s = m;
m = n;
n = s % n;
}
return n;
}
}
x87asdf