結果
問題 |
No.751 Frac #2
|
ユーザー |
|
提出日時 | 2018-11-09 21:51:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 1,423 ms |
コンパイル使用メモリ | 159,312 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 05:51:15 |
合計ジャッジ時間 | 2,184 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n1, n2; int a; pair<long long, long long> bun1, bun2 , ans; cin >> n1 >> a; bun1.first = a; bun1.second = 1; for(int i = 1;i < n1;i++){ cin >> a; bun1.second *= a; int tmp = __gcd(bun1.first, bun1.second); bun1.first /= tmp; bun1.second /= tmp; } cin >> n2 >> a; bun2.first = a; bun2.second = 1; for(int i = 1;i < n2;i++){ cin >> a; bun2.second *= a; int tmp = __gcd(bun2.first, bun2.second); bun2.first /= tmp; bun2.second /= tmp; } ans.first = bun1.first * bun2.second; ans.second = bun1.second * bun2.first; int tmp = __gcd(ans.first, ans.second); cout << ans.first/tmp << " " << ans.second/tmp << endl; return 0; }