No.280 Gear Problem (1)
タグ : / 解いたユーザー数 225
作問者 :
紙ぺーぱー
Problem Statement
You have decided to build a reduction mechanism using $N$ gears.
Although it is not very relevant to the content of the problem, the gears treated in this problem may be regarded as ideal involute gears (reference).
That is, the gears can transmit power without loss or error, and the reduction ratio does not change during rotation.
Now, gears with $z_1$,$z_2$,...,$z_N$ teeth are arranged in a row, and each gear meshes only with its adjacent gears.
It has been decided that the 1st gear is used as the input and the $N$-th gear is used as the output.
What is the reduction ratio of this reduction mechanism?
Here, for two adjacent meshing gears a and b with $z_a$ and $z_b$ teeth respectively, when a is rotated by $\theta_a$ and the angle by which b rotates is $\theta_b$, we have
$$|\theta_b| = \frac{|\theta_a| z_a}{z_b}$$and when the input $i$-th gear is rotated by $\theta_i$ and the output $j$-th gear rotates by $\theta_j$, the reduction ratio $gr$ is expressed as
$$gr = \frac{|\theta_i|}{|\theta_j|}$$
Input
$N$ $z_1$ $z_2$ ... $z_N$
The first line gives the number of gears arranged in a row, $N(2 \le N \le 50)$.
The second line gives the numbers of teeth of the gears, $z_i (10 \le z_i \le 10^{18})$, separated by spaces.
Output
Output the reduction ratio $gr$ in fraction notation.
The fraction does not need to be irreducible, but correct judgment is not guaranteed if the numerator or denominator does not fit in the range of a 64-bit signed integer, or if the numerator or denominator is negative or a decimal.
Sample
Sample 1
Input
2 20 40
Output
2/1
We have $|\theta_2| = \frac{20*|\theta_1|}{40}$.
Therefore, from $gr = \frac{|\theta_1|}{|\theta_2|}$, the reduction ratio is 2.
20/10 and 40/20 are also correct.
Sample 2
Input
3 10 10 10
Output
1/1
Both $|\theta_2|$ and $|\theta_3|$ are equal to $|\theta_1|$. Therefore, the reduction ratio is 1.
10/10, 20/20, and 100/100 are also correct.
Sample 3
Input
2 20 60
Output
60/20
The answer is correct even if the fraction is not irreducible.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。