PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000267. Căn bậc K lấy phần nguyên (Kth Root (Integer))
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Căn bậc K lấy phần nguyên (Kth Root (Integer))
Kth Root (Integer)
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
Given a non-negative integer and a positive integer , find the largest non-negative integer satisfying . Equivalently, compute . The answer must be the exact integer value, including when is a perfect -th power or lies immediately next to one.
Input
One line contains two integers and , in that order.
Output
Print one integer .
Subtasks
- Subtask 1 (20 points): and .
- Subtask 2 (30 points): and .
- Subtask 3 (50 points): and .
Examples
Example 1
Input
215 3
Output
5
Explanation
Since whereas , the floor of the cube root is .
Example 2
Input
216 3
Output
6
Explanation
Here , , but . Thus is the greatest valid integer.
Example 3
Input
18446744073709551615 2
Output
4294967295
Explanation
Here . The square of is at most , but . Thus the answer is .