結果
| 問題 |
No.280 歯車の問題(1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-01 19:26:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,050 bytes |
| コンパイル時間 | 412 ms |
| コンパイル使用メモリ | 54,492 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 01:57:49 |
| 合計ジャッジ時間 | 2,771 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 30 |
ソースコード
#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;
}