Veshy is struggling in chemistry so he asks you for help in naming hydrocarbons. As you know from chemistry, hydrocarbons are organic compounds consisting only of carbon and hydrogen atoms bonded covalently.
Covalent bonds in hydrocarbons can be either carbon-carbon single bonds (C
Given invalid
.
Input Specification
The only line of input will contain four space-separated integers,
Output Specification
There is only one line in the output.
If a valid hydrocarbon can be formed, output the chemical formula of the hydrocarbon in the form CnHm
, where
Sample Input 1
0 0 0 4
Sample Output 1
C1H4
Sample Input 2
1 0 0 3
Sample Output 2
invalid
Sample Input 3
1 0 0 6
Sample Output 3
C2H6
Explanation
In Sample 1, there are four carbon-hydrogen bonds which fills all required bonds:
In Sample 2, it is impossible to satisfy the number of covalent bonds required by the carbon atoms.
In Sample 3, each carbon atom is bonded to one other carbon atom and three other hydrogen atoms:
Comments
Why is this graph theory, shouldn't it just be implementation.
How are there comments on an editorial when there isn't one?
The test data for P1 was weak, which allowed many wrong solutions like the editorial solution to pass. We're working on a new editorial (and maybe some better test data?).
What is an example of a case that would fail many solutions?
Input:
Expected Output: