結果

問題 No.751 Frac #2
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2018-11-09 21:37:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 790 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 164,980 KB
実行使用メモリ 7,748 KB
最終ジャッジ日時 2023-08-13 11:18:52
合計ジャッジ時間 4,088 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,660 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

long long gcd(long long x,long long y){
    if(x<y) swap(x,y); //常にx>=y
    //ユークリッドの互除法
    if(!(x%y)) return y;
    else return gcd(y,x%y);
}
int main(){
    long long up=1,down=1;
    int n; cin>>n;
    rep(i,n){
        long long a; cin>>a;
        if(i) down*=a;
        else up*=a;
    }
    cin>>n;
    rep(i,n){
        long long b; cin>>b;
        if(i) up*=b;
        else down*=b;
    }
    long long div=gcd(up,down);
    cout<<up/div<<" "<<down/div<<endl;
    return 0;
}
0