Professor and balloons#9405

Professor and balloons (Editorial)

Let blue, red and yellow denote the numbers of blue, red, and yellow balloons, respectively. According to the problem statement, the following equalities hold:

From the system of equations, we find the number of balloons of each color:

Algorithm implementation

Read the input data.

scanf("%d %d %d", &n, &a, &b);

Compute and print the answer.

blue = a + b - n;
red = n - a;
yellow = n - b;
printf("%d %d %d\n", blue, red, yellow);

Java implementation

import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner con = new Scanner(System.in);
    int n = con.nextInt();
    int a = con.nextInt();
    int b = con.nextInt();
    int blue = a + b - n;
    int red = n - a;
    int yellow = n - b;
    System.out.println(blue + " " + red + " " + yellow);
    con.close();
  }
}    

Python implementation

Read the input data.

n, a, b = map(int,input().split())

Compute and print the answer.

blue = a + b - n;
red = n - a;
yellow = n - b;
print(blue, red, yellow);