Programming contests

Informatikai versenyfeladatok, 2014/2015/1

September 16, 2014 4:00 PM – December 21, 2014 8:00 PM


The FCC (Factory of Cylinders of Carbon) manufactures various types of cylinders of carbon. FCC is installed on the tenth floor of a building, and uses the several building's elevators to transport the cylinders. For security, the cylinders must be transported in the upright position, and since they are heavy, at most two cylinders can be transported in a single elevator ride. The elevators have the shape of a rectangular parallelepiped and their height is always greater than the height of the cylinders.

To minimize the number of elevator trips to transport the cylinders, the FCC wants, whenever possible, to put two cylinders in the elevator. The figure below illustrates schematically (top view) a case where this is possible (a), and a case where this is not possible (b):

As there is a very large amount of elevators and types of cylinders, FCC hired you to write a program that, given the dimensions of the elevator and of the two cylinders, determines whether it is possible to put the two cylinders in the elevator.

Input Specification

The input contains several test cases. The first and only line of each test case contains four integers W, L, R1 and R2, separated by blanks, indicating the width (1 ≤ W ≤ 100) and the length (1 ≤ L ≤ 100) of the elevator and the radii of the cylinders (1 ≤ R1R2 ≤ 100).

The last test case is followed by a line containing four zeros separated by blanks.

Output Specification

For each test case, your program should print a single line with a single character “S” if you can put the two cylinders in the elevator, and “N” otherwise.

Sample Input

  1. 11 9 2 3
  2. 7 8 3 2
  3. 10 15 3 7
  4. 8 9 3 2
  5. 0 0 0 0
download as text file

Output for Sample Input

  1. S
  2. N
  3. N
  4. S
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019