Programming contests

50 Programming Exercise for Beginners

January 2, 2019, 12:00 AM – December 31, 2019, 12:00 AM

Dog Pageant

While walking in a dog gym, someone counted the people and dogs present. By the time he got home, he forgot how many people and how many dogs he had counted, only remembering how many heads and how many legs they had.

Write a program that reads pairs of integers from the standard input until end-of-file (EOF), one pair per line. The first input number is always the number of heads counted in the tournament, and the second is the number of legs. For each input line, the program should compute and write to the standard output in a separate line the number of people and the number of dogs participating in the pageant, separated by a space character, assuming that everyone who attended the event was healthy and unharmed.

Sample Input

  1. 15 40
  2. 15 50
  3. 10 30
  4. 2 6
download as text file

Output for Sample Input

  1. 10 5
  2. 5 10
  3. 5 5
  4. 1 1
download as text file
Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
University of Debrecen; Faculty of Informatics; v. 09/30/2024