結果

問題 No.751 Frac #2
ユーザー utouto97utouto97
提出日時 2019-03-26 13:06:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 1,368 ms
コンパイル使用メモリ 161,840 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 08:44:08
合計ジャッジ時間 2,624 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

int gcd(int a, int b)
{
  if(a < b) swap(a, b);
  if(b == 0) return a;
  return gcd(b, a%b);
}

signed main()
{
  int na;
  cin >> na;
  vi a(na);
  rep(i, 0, na) cin >> a[i];

  int nb;
  cin >> nb;
  vi b(nb);
  rep(i, 0, nb) cin >> b[i];
  
  int n = a[0], m = b[0];
  rep(i, 1, nb) n *= b[i];
  rep(i, 1, na) m *= a[i];

  int g = gcd(abs(n), abs(m));
  if(m < 0) n *= -1, m *= -1;
  cout << n/g << " " << m/g << endl;

  return 0;
}
0