CodeForces344B

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+" ");

    }

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值