Programming contests

50 Programming Exercise for Beginners

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

Triangle

Determine if it is possible to produce two triangles of given side lengths, by cutting some rectangle with a single line segment.

Input Specification

The input consists of two lines. The first line contains three space-separated positive integers, indicating the desired side lengths of the first triangle. Similarly, the second line contains three space-separated positive integers, denoting the desired side lengths of the second triangle. It is guaranteed that the side lengths produce valid triangles. All side lengths are less than or equal to 100.

Output Specification

Print whether there exists a rectangle which could have been cut to form triangles of the given side lengths. If such a rectangle exists, print “YES”. Otherwise, print “NO”.

Sample Input 1

  1. 3 4 5
  2. 4 3 5
download as text file

Output for Sample Input 1

  1. YES
download as text file

Sample Input 2

  1. 3 4 6
  2. 4 6 3
download as text file

Output for Sample Input 2

  1. NO
download as text file

Sample Input 3

  1. 39 52 65
  2. 25 60 65
download as text file

Output for Sample Input 3

  1. NO
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019