#210. 递归计算整数幂

    ID: 210 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归

递归计算整数幂

Power Calculation

Background

Congcong is learning about exponentiation in mathematics. He wants to write a program to calculate the power of a number, but he is required to use recursion only, without using loops.

Problem Description

Given two positive integers basebase and nn, both of which are 11 or more. Compute recursively (no loops) the value of basebase to the nn-th power. For example, powerN(3,2)powerN(3, 2) is 99 (33 squared).

Input Format

Input is given from Standard Input in the following format.

basebase nn

Output Format

Output is printed to Standard Output in the following format.

The calculated result of basenbase^n

Sample

3 1
3
3 2
9
3 3
27

Sample Explanation

For the first sample, input 33 11 means calculating 313^1, and the result is 33. For the second sample, input 33 22 means calculating 323^2, and the result is 99. For the third sample, input 33 33 means calculating 333^3, and the result is 2727.

Constraints

For all test cases:

  • 1base1001 \le base \le 100
  • 1n151 \le n \le 15
  • Time limit: 11 second
  • Memory limit: 10241024 MiB