has been goofing off in his Science 10 class, so he has no idea what complete combustion is! Not wanting to disappoint his teacher, who thinks could do better in the class if he tried, has decided to bother you into doing his homework.
The homework sheet involves balancing hundreds of complete combustion chemical equations. In his homework, only three types of atoms (elements) are involved:
- Carbon (represented by
) - Hydrogen (represented by
) - and Oxygen (represented by
)
The general form of such an equation looks like this:
In order for the chemical equation to be balanced, the number of atoms of each element (
For example, 2CH3OH
in input/output format) contains 2 carbon atoms, 8 hydrogen atoms, and 2 oxygen atoms.
Can you help
finish his homework?Input Specification
The first and only line of input will contain a single string, C
, H
, and O
.
The total amount of each element in
Output Specification
On a single line, output the balanced chemical equation in the form of aR + bO2 -> cCO2 + dH2O
, where
If it is not possible to balance the equation, simply output Impossible
.
Sample Input 1
CH3CH2CH3
Sample Output 1
1CH3CH2CH3 + 5O2 -> 3CO2 + 4H2O
Sample Input 2
CH3OH
Sample Output 2
2CH3OH + 3O2 -> 2CO2 + 4H2O
Sample Input 3
H2O
Sample Output 3
Impossible
Comments
can someone explain why this is a WA (check batch 1 ignore the other test cases) https://dmoj.ca/submission/4544318
This might be my favourite question yet
no
can you use 0 of an element?
"a, b, c, and d to some positive integer value"
you say R cannot begin with a number yet you say 2CH3OH in the sample input
2CH3OH is not in any sample input.
A little wrong in this problem and I don't have enough time to solve problem P4, P5 and P6. So sad :(
On a single line, output the balanced chemical equation in the form of aR + bO2 -> cCO2 + dH2O, where aa, bb, cc, and dd are in lowest terms and cause the equation to be balanced, and RR is the exact copy of what was given in the input. For example, 2CH3OH2CH3OH (2CH3OH in input/output) contains 2 carbon atoms, 8 hydrogen atoms, and 2 oxygen atoms. If R is 2CH3OH then how to print output?
It is guaranteed that R will not begin with a number.
Can R is CH3(CH2)3(OH)6 ???
No, there are no brackets in R.