結果
問題 |
No.751 Frac #2
|
ユーザー |
|
提出日時 | 2019-03-15 15:55:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 657 bytes |
コンパイル時間 | 1,960 ms |
コンパイル使用メモリ | 193,464 KB |
最終ジャッジ日時 | 2025-01-06 22:10:55 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 WA * 8 |
ソースコード
#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(1LL * abs(nume), 1LL * abs(denm)); if (nume < 0 && denm < 0) { nume *= -1; denm *= -1; } if (denm == -1) { denm *= -1; nume *= -1; } cout << nume / g << " " << denm / g << endl; return 0; }