結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,424 KB
testcase_01 AC 122 ms
56,972 KB
testcase_02 AC 125 ms
56,948 KB
testcase_03 AC 124 ms
56,720 KB
testcase_04 AC 130 ms
56,496 KB
testcase_05 AC 132 ms
56,992 KB
testcase_06 AC 127 ms
56,748 KB
testcase_07 AC 124 ms
55,184 KB
testcase_08 AC 127 ms
54,800 KB
testcase_09 WA -
testcase_10 AC 125 ms
56,784 KB
testcase_11 WA -
testcase_12 AC 129 ms
56,668 KB
testcase_13 AC 127 ms
56,880 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 145 ms
56,688 KB
testcase_17 AC 141 ms
56,760 KB
testcase_18 AC 138 ms
57,136 KB
testcase_19 AC 139 ms
54,332 KB
testcase_20 AC 140 ms
56,704 KB
testcase_21 AC 142 ms
56,820 KB
testcase_22 AC 136 ms
56,792 KB
testcase_23 AC 132 ms
56,628 KB
testcase_24 AC 131 ms
56,952 KB
testcase_25 AC 127 ms
54,548 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 126 ms
56,648 KB
testcase_29 AC 128 ms
56,792 KB
testcase_30 AC 127 ms
56,764 KB
testcase_31 AC 128 ms
56,488 KB
testcase_32 AC 127 ms
57,016 KB
testcase_33 AC 127 ms
56,704 KB
testcase_34 AC 128 ms
57,032 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.nextInt();
		}
	}

	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