結果

問題 No.751 Frac #2
ユーザー aguroshouaguroshou
提出日時 2018-11-09 22:06:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,723 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 76,224 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-13 11:32:47
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 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 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	//ll n, m, q;
	int x[100] = {};
	int y[100] = {};
	c = 1;
	d = 1;
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
		if (i == 0)
		{
			c *= x[i];
		}
		else
		{
			d *= x[i];
		}
	}
	cin >> b;
	for (int i = 0; i < b; i++)
	{
		cin >> y[i];
		if (i == 0)
		{
			d *= y[i];
		}
		else
		{
			c *= y[i];
		}
	}
	e = 1;
	if (c<0)
	{
		e = -1;
		c *= -1;
	}
	f = 1;
	if (d<0)
	{
		f = -1;
		d *= -1;
	}
	for (int i = 2; i < 11; i++)
	{
		while (abs(c)%i == 0 && abs(d)%i == 0)
		{
			c /= i;
			d /= i;
		}
	}
	c *= e;
	d *= f;
	if (d<0)
	{
		c *= -1;
		d *= -1;
	}


	cout << c ;
	cout << " ";
	cout << d << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//accumulate(x, x + a, 0);
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

0