結果

問題 No.751 Frac #2
ユーザー rhincodon66rhincodon66
提出日時 2018-11-09 21:38:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 820 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 167,212 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-13 11:19:51
合計ジャッジ時間 6,562 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
4,380 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 RE -
testcase_23 RE -
testcase_24 WA -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int gcd(int, int)’ 内:
main.cpp:13:20: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   13 |                 gcd(b,a);
      |                 ~~~^~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int m;cin >> m;
	vector<int> b(m);
	rep(i,m) cin >> b.at(i);
	for(int i=2;i<n;++i){
		a.at(1)*=a.at(i);
	}
	for(int i=2;i<m;++i){
		b.at(1)*=b.at(i);
	}
	int x=0,y=0;
	if(n==1 || m==1){
		if(n==1 && m==1){
			x=a.at(0);
			y=b.at(0);
		}
		if(n==1){
			x=a.at(0)*b.at(1);
			y=b.at(0);
		}
		else{
			x=a.at(0);
			y=a.at(1)*b.at(0);
		}
	}
	else{
		x=a.at(0)*b.at(1);
		y=a.at(1)*b.at(0);
	}
	int g=gcd(x,y);
	cout << x/g << " " << y/g << endl;
}
0