結果

問題 No.751 Frac #2
ユーザー aguroshouaguroshou
提出日時 2018-11-09 23:42:55
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,722 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 05:30:05
合計ジャッジ時間 5,447 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
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 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
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: In function ‘int main()’:
main.cpp:51:23: warning: division by zero [-Wdiv-by-zero]
   51 |                 if (i %= 0)
      |                     ~~^~~~

ソースコード

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()
{

	ll 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;
	ll x[100] = {};
	ll 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 (ll 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