dsa · medium

Pow

Compute x raised to the integer power n (x**n). n may be negative; then return the reciprocal of x**(-n). Use a method that is fast enough for |n| up to 2^31 - 1.

Arguments

Example

x = 2.00000, n = 101024.00000.

x = 2.00000, n = -20.25000.

Constraints

-100.0 < x < 100.0 -2^31 <= n <= 2^31 - 1 n is an integer Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
2.0
10

Expected:
1024.0

Example 2

Input:
2.0
-2

Expected:
0.25

Open in the Dojo editor