codeforces-344b simple molecules (simulated question)

Source: Internet
Author: User

codeforces-344bSimple molecules
Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %i64d &%i64u

Submit Status

Description

Mad scientist Mike is busy carrying out experiments in chemistry. Today He'll attempt to join three atoms into one molecule.

A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom have a valence number-the number of bonds the atom must form with other atoms. An atom can form one or multiple bonds with any other atom, but it cannot form a bond with itself. The number of bonds of an atom in the molecule must is equal to its valence number.

Mike knows valence numbers of the three atoms. Find a molecule that can be built from these atoms according to the stated rules, or determine this it is impossible.

Input

The single line of the input contains three space-separated integers a, b and C (1?≤? A,? b,? c. ≤?106)-the Valence numbers of the given atoms.

Output

If such a molecule can be built, print three space-separated integers-the number of bonds between the 1-st and the 2-nd, The 2-nd and the 3-rd, the 3-rd and the 1-st atoms, correspondingly. If There is multiple solutions, output any of them. If There is no solution, print "impossible" (without the quotes).

Sample Input

Input
1 1 2
Output
0 1 1
Input
3 4 5
Output
1 3 2
Input
4 1 1
Output
Impossible

Hint

The first sample corresponds to the first figure. There is no bonds between atoms 1 and 2 in this case.

The second sample corresponds to the second figure. There is one or more bonds between each pair of atoms.

The third sample corresponds to the third figure. There is no solution, because a atom cannot form bonds with itself.

The configuration in the fourth are impossible as each atom must has at least one atomic bond.

Suppose a, B, C represent the valence of an atom.

Suppose X, y, z represent chemical bonds between atoms.

First x+y+z must be an even number, otherwise there is no solution.

Then a three-dimensional equation can be listed, consisting of 3 equations, which can be used to find the unique solution.

The only limiting condition for judging the solution is that no negative numbers can occur.


#include <iostream> #include <cstdio> #include <algorithm> #include <cmath>using namespace std; int main () {    //freopen ("D://imput.txt", "R", stdin);    int A, B, C, X, Y, Z, Temp1, Temp2;    while (Cin >> a >> b >> c) {        Temp1 = a + B + C;        Temp2 = B-a + C;        if (Temp1 & 1) {            cout << "impossible" << Endl;            Continue;        }        if (Temp2 & 1) {            cout << "impossible" << Endl;            Continue;        }        x = A-(Z = c-(y = TEMP2/2));        if (x < 0 | | Y < 0 | | Z < 0) {            cout << "impossible" << Endl;            Continue;        }        cout << x << "<< y <<" "<< z << endl;    }    return 0;}



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

codeforces-344b simple molecules (mock question)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.