JCC25 Contest 1 P3 - Percentage Composition


Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Assembly, Awk, Brain****, C, C++, Java, Lua, Pascal, Perl, PyPy 2, PyPy 3, Python, Sed

Jason has forgotten how to calculate percentage composition, help him out! He is trying to calculate the percent composition for a molecule comprised of \(N\) unique elements.

The percent composition of a compound is how much of the total mass of the compound is formed by each element.

\(H_2O\) has 2 Hydrogens and 1 Oxygen. The mass of Hydrogen is approximately \(1\ grams/mol\) and the mass of Oxygen is approximately \(16\ grams/mol\). The total mass for \(H_2O\) is \(18\ grams/mol\)

The percentage composition for \(H_2O\) is approximately \(11\%\) Hydrogen and \(89\%\) Oxygen

Constraints

Subtask 1 [40%]

\(N = 2\)

Subtask 2 [60%]

\(2 \le N \le 50\)

Input Specification

The first line will contain \(N\)

The next \(N\) lines will contain one integer per line, the amount of an element \(a_i\)

The next \(N\) lines will contain one integer per line, the mass of the element \(a_i\)

Output Specification

Output \(N\) space seperated integers representing the percent composition of each element \(a_i\).

All percentages will be integers so do not worry about float rounding!

Be careful about integer truncation!

Sample Input

2
16
8
10
5

Sample Output

80 20

Explanation for Sample Output

There are 16 of element 1 and 8 of element 2

Each element 1 weighs 10 and each element 2 weighs 5

The total compound weighs \(16*10 + 8*5 = 200\)

All of element 1 weighs \(16*10=160\) comprising \(\frac{160}{200}*100\%=80\%\)

All of element 2 weighs \(8*5=40\) comprising \(\frac{40}{200}*100\%=20\%\)


Comments

There are no comments at the moment.