結果

問題 No.751 Frac #2
ユーザー x87asdfx87asdf
提出日時 2018-11-15 17:16:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 898 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 75,788 KB
実行使用メモリ 58,720 KB
最終ジャッジ日時 2023-08-26 01:19:36
合計ジャッジ時間 8,019 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
56,516 KB
testcase_01 AC 127 ms
56,696 KB
testcase_02 AC 129 ms
56,776 KB
testcase_03 AC 125 ms
56,904 KB
testcase_04 AC 124 ms
56,716 KB
testcase_05 AC 124 ms
56,548 KB
testcase_06 AC 131 ms
56,972 KB
testcase_07 AC 128 ms
56,828 KB
testcase_08 AC 130 ms
56,344 KB
testcase_09 WA -
testcase_10 AC 126 ms
56,960 KB
testcase_11 WA -
testcase_12 AC 123 ms
56,708 KB
testcase_13 AC 128 ms
56,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 143 ms
56,760 KB
testcase_17 AC 124 ms
56,784 KB
testcase_18 AC 138 ms
56,492 KB
testcase_19 AC 135 ms
56,704 KB
testcase_20 AC 130 ms
56,772 KB
testcase_21 AC 126 ms
56,872 KB
testcase_22 AC 126 ms
56,980 KB
testcase_23 AC 126 ms
56,788 KB
testcase_24 AC 128 ms
57,040 KB
testcase_25 AC 126 ms
56,832 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 127 ms
57,228 KB
testcase_29 AC 130 ms
54,724 KB
testcase_30 AC 134 ms
56,524 KB
testcase_31 AC 129 ms
56,812 KB
testcase_32 AC 128 ms
56,668 KB
testcase_33 AC 127 ms
56,852 KB
testcase_34 AC 132 ms
56,780 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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.nextLong();
		}
	}

	static void inputDeno(int l) {
		for(int i=0;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;
	}
}
0