結果
| 問題 | 
                            No.751 Frac #2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yuruhiya
                         | 
                    
| 提出日時 | 2019-02-05 19:05:49 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,813 bytes | 
| コンパイル時間 | 1,061 ms | 
| コンパイル使用メモリ | 104,536 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2025-01-03 00:07:10 | 
| 合計ジャッジ時間 | 2,364 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 WA * 30 RE * 2 | 
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
//最大公約数
LL gcd(LL n, LL m) {
	if (m == 0)return n;
	return gcd(m, n%m);
}
//最小公倍数
LL lcm(LL n, LL m) {
	LL g = gcd(n, m);
	return n / g * m;
}
pair<LL, LL> abc(LL a, LL b) {
	LL g = gcd(a, b);
	return mp(a / g, b / g);
}
int main() {
	LL n; cin >> n;
	vector<LL> a(n); rep(i, n)cin >> a[i];
	LL m; cin >> m;
	vector<LL> b(m); rep(i, m)cin >> b[i];
	while (sz(a) > 2) {
		LL x = a[1] * a[2];
		a.erase(a.begin() + 1);
		a.erase(a.begin() + 1);
		a.insert(a.begin() + 1, x);
		pair<LL, LL> a3 = abc(a[0], a[1]);
		a[0] = a3.first;
		a[1] = a3.second;
	}
	while (sz(b) > 2) {
		LL x = b[1] * b[2];
		b.erase(b.begin() + 1);
		b.erase(b.begin() + 1);
		b.insert(b.begin() + 1, x);
		pair<LL, LL> b3 = abc(b[0], b[1]);
		b[0] = b3.first;
		b[1] = b3.second;
	}
	LL A = a[0] * b[1], B = b[0] * a[1];
	LL g = gcd(A, B);
	cout << A / g << " " << B / g << endl;
}
            
            
            
        
            
yuruhiya