Median Modulo

View as PDF

Submit solution


Points: 15 (partial)
Time limit: 3.0s
Memory limit: 256M

Author:
Problem type

You are given a positive integer N. Calculate the lower median of the numbers Nmod1,Nmod2,Nmod3,,NmodN.

The lower median of a sequence of k numbers is the number at position k+12 when the sequence is sorted. For example, the lower median of the sequence 1,3,5,7 is 3 and the lower median of the sequence 1,1,2,3,5 is 2.

Input Specification

The first and only line of input contains the integer N.

Constraints

Subtask 1 [10%]

1N106

Subtask 2 [20%]

1N109

Subtask 3 [20%]

1N1012

Subtask 4 [25%]

1N1015

Subtask 5 [25%]

1N1018

Output Specification

Output one number: the lower median in the problem statement.

Sample Input 1

Copy
7

Sample Output 1

Copy
1

Explanation for Sample Output 1

The sequence 7mod1,7mod2,7mod3,7mod4,7mod5,7mod6,7mod7 is equal to 0,1,1,3,2,1,0. When sorted, this becomes 0,0,1,1,1,2,3. The lower median is the 4th element of this sorted sequence, which is 1.

Sample Input 2

Copy
50

Sample Output 2

Copy
6

Comments

There are no comments at the moment.