#BS0000387. Căn bậc ba gần đúng (Pretty Good Cube Root)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Căn bậc ba gần đúng (Pretty Good Cube Root)
Pretty Good Cube Root
Version: Phuoc Hung OJ Extended
PHOJ practice edition. Its constraints, input/output format, examples and judging rules are specified below.
Problem Statement
Given a positive integer , find a nonnegative integer minimizing . If two values achieve the minimum difference, choose the larger one.
Input
One line contains a positive decimal integer without leading zeros.
Output
Print the required integer .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Created examples
Input
27
Output
3
Explanation
For , choosing gives . The difference is zero, the smallest possible.
Input
14
Output
2
Explanation
For , the adjacent cubes are and . Their differences are and . Thus is better, and more distant cubes cannot improve it.
Input
20
Output
3
Explanation
For , the adjacent cubes are 8 and 27. The differences are and . Choose since 7 is smaller than 12.
Input
16
Output
2
Explanation
For , the adjacent cubes are 8 and 27, with differences and . Under the cube-distance criterion of this draft, choose 2.