CodeForces344B

来源:互联网 发布:淘宝详情页ps怎么切片 编辑:程序博客网 时间:2024/06/06 14:19

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

A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has 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 be 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 that 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 are multiple solutions, output any of them. If there is no solution, print “Impossible” (without the quotes).

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

import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;import java.util.Arrays;import java.util.Scanner;/** * Created by 95112 on 10/22/2017. */public class Molecule {    public static void main(String[] args)    {        Scanner scanner = new Scanner(System.in);        int[] atoms = new int[3];        int[] storageAtoms = new int[3];        int[] answer = new int[3];        for (int i =0 ; i< 3 ; i++) {            atoms[i] = scanner.nextInt();            storageAtoms[i] = atoms[i];        }        Arrays.sort(atoms);        if (atoms[0] <= 0 )        {            System.out.println("Impossible");            return;        }        if (atoms[2] > atoms[1]+atoms[0]){            System.out.println("Impossible");            return;        }        int dValue = atoms[1] - atoms[0];        if ((atoms[2] - dValue)%2 == 1)        {            System.out.println("Impossible");            return;        }        else {            int tmpDValue = storageAtoms[1] - storageAtoms[2];           if (tmpDValue < 0 ){               answer[0] =( storageAtoms[0] + tmpDValue)/2;               answer[2] = answer[0] - tmpDValue;               answer[1] = storageAtoms[1] - answer[0];           }           else {               answer[0] = (storageAtoms[0] - tmpDValue)/2 + tmpDValue;               answer[2] = (storageAtoms[0] - tmpDValue)/2;               answer[1] = storageAtoms[1] - answer[0];           }        }        for (int ans : answer)            System.out.print(ans+" ");    }}
原创粉丝点击