結果

問題 No.751 Frac #2
ユーザー polylogK
提出日時 2018-11-09 21:32:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 538 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 167,668 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-21 05:39:53
合計ジャッジ時間 2,471 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; cin >> n;
	i64 A = 1, B = 1; cin >> A;
	for(int i = 1; i < n; i++) {
		i64 a; cin >> a;
		B *= a;
	}
	int m; cin >> m;
	i64 X = 1, Y = 1;
	for(int i = 0; i < m - 1; i++) {
		i64 b; cin >> b;
		X *= b;
	}
	cin >> Y;
	
	i64 latte = X * B, malta = A * Y;
	i64 G = std::__gcd(latte, malta);
	latte /= G;
	malta /= G;
	if(latte < 0) {
		latte *= -1;
		malta *= -1;
	}
	
	cout << malta << " " << latte << endl;
	return 0;
}
0