結果
| 問題 |
No.751 Frac #2
|
| コンテスト | |
| ユーザー |
nasu_ysmr
|
| 提出日時 | 2019-02-19 18:36:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 793 bytes |
| コンパイル時間 | 1,581 ms |
| コンパイル使用メモリ | 167,336 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-12 13:48:27 |
| 合計ジャッジ時間 | 3,059 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 WA * 6 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int gojoho(int a, int b){
while(1){
b %= a;
if(b==0) break;
else swap(a,b);
}
return a;
}
int main(){
int Bunbo=1;
int Bunshi=1;
int A;
int B;
int Na, Nb;
int i;
int Kouyakusu;
scanf("%d", &Na);
for(i=0; i<Na; i++){
scanf("%d", &A);
if(i==0) Bunshi *= A;
else Bunbo *= A;
}
scanf("%d", &Nb);
for(i=0; i<Nb; i++){
scanf("%d", &B);
if(i%2==0) Bunbo *= B;
else Bunshi *= B;
}
Kouyakusu = gojoho(Bunbo,Bunshi);
Bunbo /= Kouyakusu;
Bunshi /= Kouyakusu;
if(Bunbo<0){
Bunbo*=-1;
Bunshi*=-1;
}
printf("%d %d", Bunshi, Bunbo);
return 0;
}
nasu_ysmr