PIB '20 P2 - 2 + 2 = 5

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 0.5s
Memory limit: 128M

Author:
Problem type

Josh loves solving problems. However, solving problems takes a lot of time, so he will sometimes batch problems together, which allows him to solve them quicker. He will do it according to the following rules:

  • Every 2 problems take him 1 minute to solve (rounded down).
  • Every 7 problems take him 1 less minute to solve than usual.

Some examples:

  • Solving 8 problems takes Josh \frac 8 2 - \left\lfloor \frac 8 7 \right\rfloor = 4 - 1 = 3 minutes. It takes him 4 minutes to solve the problems usually. However, since he's solved 8 problems, and every 7 problems take 1 less minute, he will only take 4 - 1 = 3 minutes.
  • Solving 7 problems takes Josh \left\lfloor \frac 7 2 \right\rfloor - 1 = 2 minutes in total.
  • Solving 1 problem takes Josh 0 - 0 = 0 minutes.

Josh has only T minutes to solve as many problems as possible. Can you determine the maximum number of problems he can solve?

Input Specification

The first line will contain the integer T (1 \le T \le 10^{14}).

Output Specification

Output the maximum number of problems Josh can solve in T minutes.

Subtasks

Subtask 1 [37%]

T \le 10^6

Subtask 2 [63%]

No additional constraints.

Sample Input for Subtask 1

5

Sample Output for Subtask 1

15

Explanation for Sample for Subtask 1

Solving 15 problems takes him \left\lfloor \frac{15} 2 \right\rfloor - \left\lfloor \frac{15} 7 \right\rfloor = 7 - 2 = 5 minutes, which is exactly the amount of time he has.

Sample Input for Subtask 2

1000000007

Sample Output for Subtask 2

2800000021

Comments


  • 0
    PhoenixCoolIce  commented on March 1, 2024, 6:40 p.m.

    technically, if one problem takes zero minutes, doesn't 1000000007 minutes give infinite?