9405. Professor and balloons
For the celebration, the Professor bought
balloons of three colors: blue, red, and yellow. In total, he bought n
balloons. The number of yellow and blue balloons is a, and the number of
red and blue balloons is b.
Determine how many blue, red, and yellow
balloons the Professor bought.
Input. Three positive integers n, a, b.
Output. Print in one line the number of blue, red, and yellow
balloons bought by the Professor.
|
Sample
input |
Sample
output |
|
10 6 8 |
4 4 2 |
mathematics
Let blue, red and yellow denote the numbers of blue, red, and yellow
balloons, respectively. According to the problem statement, the following
equalities hold:
·
yellow + blue = a
(yellow and blue balloons);
·
red + blue = b
(red and blue balloons);
·
blue + red + yellow = n (the total number of balloons)

· red = n – a;
· yellow = n – b;
· blue = a + b – n;
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);
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();
}
}
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);