結果

問題 No.751 Frac #2
ユーザー 👑 CleyL
提出日時 2020-02-27 15:34:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 561 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 63,752 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 15:57:25
合計ジャッジ時間 1,575 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
int main(){
    long long S = 1;
    long long B = 1;
    int a;cin>>a;
    for(int i = 0; a > i; i++){
        long long t;cin>>t;
        if(i){
            B *= t;
        }else{
            S *= t;
        }
    }
    cin>>a;
    for(int i = 0; a > i; i++){
        long long t;cin>>t;
        if(i%2){
            S *= t;
        }else{
            B *= t;
        }
    }
    cout << S/gcd(S,B) << " " << B/gcd(S,B) << endl;
}
0