Annoying Chemistry

3.8

85 votes
Mathematics, Number Theory, GCD, Math, Number theory
Problem

You are given a chemical equation of the following format:

(b1)Cx+(b2)Hy > (b3)CpHq

Your task is to calculate the balancing factor b1, b2, and b3 such that the number of atoms of each of the elements is equal on both sides.

Note: The answer must be in a reduced form.

Input format

The first line consists of four integers x, y, p, and q.

Output format

The output must contain b1, b2, and b3.

Constraints

1x1041y1041p1041q104

Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Given chemical equation is :

C2  +  H3     -------->    C4 H5

The balanced chemical equation is:

6 C2  + 5 H3     -------->    3 C4 H5

 

Editor Image

?