Programming contests

ECN selejtező programozó csapatverseny, 2014. április 27.

April 27, 2014 10:30 AM – April 27, 2014 3:30 PM

Making Quadrilaterals

A quadrilateral is a simple geometric shape. The formal definition of a quadrilateral for this problem can be given as follows:

A quadrilateral is a simple polygon with four sides, having a strictly positive area.

If you are given four rods made of steel and having integer length, you may or may not be able to make a quadrilateral with it. For example, you cannot make a quadrilateral with four rods of length 4, 5, 8, and 17 units, but you can make a quadrilateral with four rods of length 2, 3, 4, and 5 units, respectively. Now you have to supply n rods to the Architecture Department of a university. But the university authority has asked you to make the lengths of the rods such that no four of them can be used to make a quadrilateral. They are afraid that if the students can make such shapes, then they will use up some of the rods in the sculptures they make. Given the value of n, what is the minimum possible length of the longest rod? You can assume that

  1. only one rod has to be used as one side of the quadrilateral;
  2. a rod cannot be divided into two smaller pieces;
  3. two or more rods cannot be joined to make a longer rod.

Input Specification

The input contains at most 100 lines. Each line contains an integer, which denotes the value of n (3 < n < 61). A line containing a 0 (zero) terminates the input.

Output Specification

For each line of input, produce one line of output. This line contains the case number followed by a decimal integer that denotes the shortest possible length of the longest rod. You can safely assume that this length will fit in a 64-bit signed integer. Look at the output for sample input for details.

Sample Input

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

Output for Sample Input

  1. Case 1: 3
  2. Case 2: 9
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019