#GD0000183. Tăng và sao chép (Increase and Copy)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tăng và sao chép (Increase and Copy)
Increase and Copy
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Initially, the array contains a single element . In one operation you may either increment one existing element by , or append a copy of the value of one existing element to the end of the array. Operations may be performed in any order. Your goal is to make the sum of the array at least using as few operations as possible.
Input
The only line contains the integer , the minimum required array sum.
Output
Print one integer: the minimum number of operations required to reach total sum at least .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
42
Output
11
Explanation
Start with . Increment its only element six times to get (six operations), then append five copies of . The final six entries sum to (five more operations). This uses operations, and balancing increments with copies cannot improve on it.
Example 2
Input
1
Output
0
Explanation
The initial array already sums to , which meets the target , so no operations are necessary.