首页 > 代码库 > 网易2017 计算糖果

网易2017 计算糖果

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner ins = new Scanner(System.in);
        while (ins.hasNextInt()) {//注意while处理多个case 
            int in[]=new int[4];
             in[0] = ins.nextInt();
               in[1] = ins.nextInt();
             in[2] = ins.nextInt();
             in[3] = ins.nextInt(); 
            if ((in[0] + in[2]) % 2 != 0 || (in[1] + in[3]) % 2 != 0 || (in[0] + in[2])<0 ||(in[1] + in[3]) <0 ) {
            System.out.println("No");
        } else {
            int A = (in[0] + in[2]) / 2;
            int B = (in[1] + in[3]) / 2;
            int A2BC = in[3] + in[2];
            int C = A2BC - 2 * B - A;
            System.out.println(String.valueOf(A)+" "+String.valueOf(B)+" "+String.valueOf(C));
        }

           
        }
    }
}

 

网易2017 计算糖果