結果

問題 No.751 Frac #2
ユーザー 41Toame41Toame
提出日時 2018-12-23 10:47:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 1,065 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 159,992 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 02:28:26
合計ジャッジ時間 2,861 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n1; cin >> n1;
    int A[10]; 
    rep(i, n1) cin >> A[i];
    int n2; cin >> n2;
    int B[10];
    rep(i, n2) cin >> B[i];
    int up = 1;
    int down = 1;
    up *= A[0];
    for(int i = 1; i < n1; i++) down *= A[i];
    for(int i = 1; i < n2; i += 2) up *= B[i];
    for(int i = 0; i < n2; i += 2) down *= B[i];
    REP(i, 2, 1000000) {
        while (up % i == 0 && down % i == 0) {
            up /= i;
            down /= i;
        }
    }
    if (down < 0) {
        down *= -1;
        up *= -1;
    }
    cout << up << " " << down << endl;

    return 0;
}
0