Programming contests

Magas szintű programozási nyelvek 1, gyakorló feladatsor, 2012. február 20.

February 25, 2014, 12:00 PM – April 10, 2014, 12:00 AM

Sushi Party

You are organizing a party for your friends. To have some food for the evening, you bought some number of sushi rolls. In order to avoid any bad feelings, you want to ensure that everyone gets the same number of sushi rolls (including you), but everyone has to get more than one. For example, if you have 20 sushi rolls, then you can invite 1, 3, 4, or 9 friends. Your task is to write a program that, given the number of sushi rolls, gives you a suggestion on how many friends to invite.

Input Specification

The input contains several blocks of test cases. Each test case consists of a single line containing a single integer 1 ≤ n ≤ 10 000. The input is terminating by a line containing '0'.

Output Specification

For each test case, you have to output a single positive integer on a separate line: a possible number of guests to invite. If it is not possible to invite guests at all for this number of sushi rolls, then output 'No solution.' (without the quotes).

Sample Input

  1. 12
  2. 14
  3. 11
  4. 20
  5. 0
download as text file

Output for Sample Input

  1. 5
  2. 6
  3. No solution.
  4. 9
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024