1482 Maester’s problem

Time Limit : 2000/1000 MS(Java/Others) | Memory Limit : 65536/32768 KB(Java/Others)

Submits : 4 | Solved : 1

Description

″You are too young to be burdened with all my cares,″ the father told them, ″but you are also the Starks of Winterfell. You know our words.″

″Winter is coming,″ His sons whispered.

″Those who would truly do us harm, live in the King's Landing with their best pleasure. What can we do to prevent from their invasion?″

″Patiently, my lord.″ the prime minister of Stark said, ″ Some of your sons have handed in several opinions to the throne. Surprisingly, considering one's all opinions that he handed in, no one's all opinions are exactly the same as another's all. What's more, any two of them handed at least one same opinion. How many of your sons are there had handed in opinions?″

″............″ Ned Stark frowned.

Input

There are multiple cases. Each line is a test case, and it will contain one integer, N, (1 ≤ N ≤ 100)
indicating the number of distinct opinions we received so far.

Output

For each case, output one integer, the maximum possible number of sons who had handed some opinions. 
As the number may be so large, output it modulo 5.

Sample Input

1
2

Sample Output

1
2

HINT

Considering the test case 2, there are 2 opinions handed in, maybe one son handed the No.1 and No.2 opinion,
 and the other son handed the No.2 opinion.
So they both handed one same opinion, but no one's ALL opinions are same as the other's. 
The number of sons who had ever handed in opinions, can't be more than 2 in the second test case.

Source

ZJU

[ Top ] | [ Submit ]