JCC25 Contest 1 P5 - Empirical Formula
Jason is trying to find the empirical formula of a molecule
The empirical formula of a molecule is the simplest whole number ratio of atoms present in a compound.
For example glucose, \(C_6H_{12}O_6\) has the empirical formula \(CH_2O\)
Another example is \(C_4H_6\) which has the empirical formula \(C_2H_3\)
Given the amounts of \(N\) elements, \(x_i\), determine the empirical formula
Constraints
Subtask 1 [20%]
\(N = 2\)
\(1 \le x_i \le 10 ^ 2\)
Subtask 2 [40%]
\(N = 2\)
\(1 \le x_i \le 10 ^ {18}\)
Subtask 3 [40%]
\(3 \le N \le 10 ^ 2\)
\(1 \le x_i \le 10 ^ {18}\)
Input Specification
The first line will contain one integer \(N\)
The next \(N\) lines will contain one integer \(x_i\)
Output Specification
Output \(N\) space seperated integers representing the ratio of the atoms in empirical form
Sample Input
3
6
12
6
Sample Output
1 2 1
Explanation for Sample Output
The ratio of the atoms are 6 to 12 to 6. In simplest form this is 1 to 2 to 1.
Comments