結果

問題 No.751 Frac #2
ユーザー yuruhiyayuruhiya
提出日時 2019-02-05 19:00:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,582 bytes
コンパイル時間 2,263 ms
コンパイル使用メモリ 97,932 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-30 23:55:58
合計ジャッジ時間 2,430 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 RE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

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);
	}
	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);
	}
	LL A = a[0] * b[1], B = b[0] * a[1];
	LL g = gcd(A, B);
	cout << A / g << " " << B / g << endl;
}
0