Programming contests

50 Programming Exercise for Beginners

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

Equal Values

Write a program that reads one or more nonnegative integers from the standard input line by line. If the first number of the line is 0, the program should end its operation. If the first number of the line is positive, it indicates the number of additional numbers in the line.

For each input line, the program should write the string „YES” to the standard output if the second number in the line is the same as the last one, otherwise the string „NO” should be printed.

Sample Input

  1. 4 2 5 2 1
  2. 5 11 5 133 62 11
  3. 1 1
  4. 4 1 0 1 2
  5. 3 1 0 1
  6. 0
download as text file

Output for Sample Input

  1. NO
  2. YES
  3. YES
  4. NO
  5. YES
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