結果
| 問題 |
No.751 Frac #2
|
| コンテスト | |
| ユーザー |
chocopuu
|
| 提出日時 | 2018-11-10 20:40:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 880 bytes |
| コンパイル時間 | 1,541 ms |
| コンパイル使用メモリ | 168,076 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-25 00:16:59 |
| 合計ジャッジ時間 | 2,685 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 |
ソースコード
#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,x;
cin >> N ;
for(int i = 0 ; i < N ; i++){
cin >> x ;
if (x<0)
{
cnt++;
}
if (i==0) {
A*=x;
} else {
B*=x;
}
}
int M;
cin >> M ;
for(int i = 0 ; i < M ; i++){
cin >> x ;
if (x<0)
{
cnt++;
}
if (i%2==0) {
B*=x;
} else {
A*=x;
}
}
x=gcd(abs(A),abs(B));
cout << abs(A)/x*(pow(-1,(cnt%2))) <<" " <<abs(B)/x << "\n";
return 0;
}
chocopuu