結果
| 問題 |
No.751 Frac #2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-15 15:53:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 523 bytes |
| コンパイル時間 | 2,090 ms |
| コンパイル使用メモリ | 192,732 KB |
| 最終ジャッジ日時 | 2025-01-06 22:10:46 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 WA * 18 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
long long nume = 1, denm = 1;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (i == 0) nume *= x;
else denm *= x;
}
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (i % 2 == 1) nume *= x;
else denm *= x;
}
long long g = __gcd(abs(nume), abs(denm));
cout << nume / g << " " << denm / g << endl;
return 0;
}