P1994 Combustion of Organic Compounds
Background
I originally planned to make it harder, but never mind.
Description
Given an organic compound containing only $ \text{C, H, O} $ elements, output the coefficients of $ \mathrm{CO_2} $ and $ \mathrm{H_2O} $ in the balanced chemical equation for its reaction with oxygen.
Input Format
One line, a string representing the organic compound.
Output Format
Two numbers, which are the coefficients of $ \mathrm{CO_2} $ and $ \mathrm{H_2O} $, respectively.
Explanation/Hint
Sample explanation:
$$\mathrm{C_2H_5OH + 3 O_2 \xlongequal{\text{点燃}} 2 CO_2 + 3 H_2O} $$
---
For $100\%$ of the testdata:
- The string length does not exceed $10$.
- The coefficients of $ \mathrm{CO_2} $ and $ \mathrm{H_2O} $ to be found do not exceed $400$.
- The given organic compound is valid and contains only $ \text{C, H, O} $ elements.
Translated by ChatGPT 5