結果

問題 No.751 Frac #2
ユーザー chocopuuchocopuu
提出日時 2018-11-10 20:28:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 165,356 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-16 11:26:39
合計ジャッジ時間 3,229 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1000000007;
const int INF=1e18;
int gcd(int x,int y){if(x==0)return y;return gcd(y%x,x);}
int lcm(int x, int y){return(x*y/gcd(x, y));}

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);

    int A = 1,B = 1;
    int cnt = 0;

    int N;
    std::cin >> N ;
    for(int i = 0 ; i < N ; i++){
        int x;
        std::cin >> x ;
        if (x<0)
        {
            cnt++;
        }
        if (i==0) {
            A*=x;
        } else {
            B*=x;
        }
    }
    int M;
    std::cin >> M ;
    for(int i = 0 ; i < M ; i++){
        int x;
        std::cin >> x ;
        if (x<0)
        {
            cnt++;
        }
        if (i%2==0) {
            B*=x;
        } else {
            A*=x;
        }
    }
    int x=gcd(abs(A),abs(B));

    std::cout << abs(A)/x*(-1*(cnt%2)) <<" " <<abs(B)/x << "\n";
    return 0;
}
0