結果

問題 No.751 Frac #2
ユーザー ngtkana
提出日時 2020-03-14 20:48:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 469 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 192,092 KB
最終ジャッジ日時 2025-01-09 06:55:44
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    lint a=1,b=1;
    lint n;std::cin>>n;
    lint x;
    for(lint i=0;i<n;i++){
        std::cin>>x;
        (i?b:a)*=x;
    }
    std::cin>>n;
    for(lint i=0;i<n;i++){
        lint x;std::cin>>x;
        (i%2?a:b)*=x;
    }
    if(a<0)a=-a,b=-b;
    lint g=std::__gcd(a,b);
    std::cout<<a/g<<" "<<b/g<<'\n';
}
0