結果
問題 | No.751 Frac #2 |
ユーザー |
![]() |
提出日時 | 2018-11-30 16:07:00 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 687 ms |
コンパイル使用メモリ | 80,772 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-26 23:40:31 |
合計ジャッジ時間 | 1,878 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 28 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <complex> #include <stack> #include <queue> #include <unordered_map> using namespace std; int main(){ int n1, n2; int a1; int a2 = 1; int b1; int b2 = 1; int tmpa, tmpb; cin >> n1; int i; cin >> a1; for(i = 0; i < n1 - 1; i++){ cin >> tmpa; a2 *= tmpa; } cin >> n2; cin >> b1; for(i = 0; i < n2 - 1; i++){ cin >> tmpb; b2 *= tmpb; } int ans1, ans2; ans1 = a1 * b2; ans2 = a2 * b1; int a = ans1; int b = ans2; int tmp, r; /* 自然数 a > b を確認・入替 */ if(a<b){ tmp = a; a = b; b = tmp; } /* ユークリッドの互除法 */ r = a % b; while(r!=0){ a = b; b = r; r = a % b; } ans1 /= b; ans2 /= b; cout << ans1 << " " << ans2 << endl; }