题解 | #计算糖果#
计算糖果
https://www.nowcoder.com/practice/02d8d42b197646a5bbd0a98785bb3a34
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // 注意 hasNext 和 hasNextLine 的区别 int x = in.nextInt(); int y = in.nextInt(); int z = in.nextInt(); int m = in.nextInt(); int A = (x+z)/2; int B = (z-x)/2; int C = (m-B); if((x+z)%2==0&&(z-x)%2==0&&A>=0&&B>=0&&C>=0) System.out.println(A+" "+B+" "+C); else System.out.println("No"); } }