結果

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

ソースコード

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; cin >> X;
	for(int i = 1; i < m; i++) {
		i64 b; cin >> b;
		Y *= b;
	}
	
	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