結果

問題 No.280 歯車の問題(1)
ユーザー KlayKlay
提出日時 2017-05-01 19:26:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,050 bytes
コンパイル時間 374 ms
コンパイル使用メモリ 52,552 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 02:09:25
合計ジャッジ時間 5,259 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

/*
歯車の問題(1)

2
20 40

Z1 * theta1 = Z2 * theta2 => Z1 : Z2 = theta2 : theta1

theta2 = theta1 * (Z1 / Z2)

gr = theta1 / theta2 = Z2 / Z1

3
20 40 80
1  2  3

theta2 = theta1 * (20 / 40) = 0.5 * theta1
theta3 = theta2 * (40 / 80) = 0.5 * theta2

theta3 = 0.5 * 0.5 * theta1

theta1 / theta3 = 1 / (0.5 * 0.5)
*/

class FRACTION
{
	public:
	
	int numerator, denominator;
	
	FRACTION operator*(FRACTION frac)
	{
		FRACTION answer;
		
		answer.numerator = numerator * frac.numerator;
		answer.denominator = denominator * frac.denominator;
		
		return answer;
	}
};

FRACTION getGR(int N1, int N2)
{
	FRACTION GR;
	
	GR.numerator = N2;
	GR.denominator = N1;

	return GR;
}

int main(void)
{
	FRACTION GR;
	GR.numerator = 1;
	GR.denominator = 1;

	int N;

	std::cin >> N;
	
	int Z[N];
	
	for(int i = 0; i < N; i ++)
	{
		std::cin >> Z[i];
	}
	
	for(int i = 0; i < N - 1; i ++)
	{
		GR = GR * getGR(Z[i], Z[i + 1]);
	}
	
	std::cout << GR.numerator << "/" << GR.denominator << std::endl;
	
	return 0;
}























0