結果
| 問題 |
No.751 Frac #2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-15 14:06:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,511 bytes |
| コンパイル時間 | 1,586 ms |
| コンパイル使用メモリ | 167,952 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-22 01:42:38 |
| 合計ジャッジ時間 | 2,521 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 WA * 33 |
ソースコード
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
long long GCD(long long a, long long b) {
if (b == 0)
return a;
else
return GCD(b, a % b);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int upp_bunshi = 0, upp_bunbo = 1, upp_bunshi_togo = 1, upp_bunbo_togo = 1;
int low_bunshi = 0, low_bunbo = 1, low_bunshi_togo = 1, low_bunbo_togo = 1;
int n1;
cin >> n1;
rep(i, n1) {
int a;
cin >> a;
if (i == 0) {
upp_bunshi = a;
if (a < 0)
upp_bunshi_togo = -1;
} else
upp_bunbo *= a;
if (a < 0)
upp_bunbo_togo *= -1;
}
int n2;
cin >> n2;
rep(i, n2) {
int a;
cin >> a;
if (i == 0) {
low_bunshi = a;
if (a < 0)
low_bunshi_togo = -1;
} else
low_bunbo *= a;
if (a < 0)
low_bunbo_togo *= -1;
}
int ans_bunshi =
upp_bunshi_togo * low_bunbo_togo * abs(upp_bunshi) * abs(low_bunbo),
ans_bunbo =
upp_bunbo_togo * low_bunshi_togo * abs(upp_bunbo) * abs(low_bunshi);
int gcd = GCD(abs(ans_bunbo), abs(ans_bunshi));
ans_bunbo /= gcd, ans_bunshi /= gcd;
cout << ans_bunshi << " " << ans_bunbo << endl;
}