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

Bài tập thuộc lộ trình

1 lộ trình

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 AA and a positive integer KK, find the largest non-negative integer xx satisfying xK≤Ax^K\le A. Equivalently, compute ⌊A1/K⌋\lfloor A^{1/K}\rfloor. The answer must be the exact integer value, including when AA is a perfect KK-th power or lies immediately next to one.

Input

One line contains two integers AA and KK, in that order.

Output

Print one integer x=⌊A1/K⌋x=\lfloor A^{1/K}\rfloor.

Subtasks

  • Subtask 1 (20 points): 0≤A≤1060\le A\le 10^6 and 1≤K≤641\le K\le64.
  • Subtask 2 (30 points): 0≤A≤10120\le A\le10^{12} and 1≤K≤641\le K\le64.
  • Subtask 3 (50 points): 0≤A≤264−10\le A\le2^{64}-1 and 1≤K≤641\le K\le64.

Examples

Example 1

Input

215 3

Output

5

Explanation

Since 53=125≤2155^3=125\le215 whereas 63=216>2156^3=216>215, the floor of the cube root is 55.

Example 2

Input

216 3

Output

6

Explanation

Here 53=125<2165^3=125<216, 63=216=A6^3=216=A, but 73=343>A7^3=343>A. Thus 66 is the greatest valid integer.

Example 3

Input

18446744073709551615 2

Output

4294967295

Explanation

Here A=264−1A=2^{64}-1. The square of 232−12^{32}-1 is at most AA, but (232)2>A(2^{32})^2>A. Thus the answer is 42949672954294967295.