開方數
時間限制:500 ms | 內存限制:65535 KB
難度:3
-
描述
- 現在給你兩個數 n 和 p ,讓你求出 p 的開 n 次方。
-
輸入
- 每組數據包含兩個數n和p。當n和p都爲0時表示輸入結束。(1<=n<=200,1<=p<=10^101)
-
輸出
- 對於每個輸出對用輸出開方後的結果k(結果小於10^9)。
-
樣例輸入
-
2 16
3 27
7 4357186184021382204544
0 0
-
樣例輸出
-
4
3
1234
import java.util.Scanner;
public class Main {//Accepted 40 495 java 2014-03-12 21:22:17
public static void main(String[] args){
Scanner input=new Scanner(System.in);
//BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
while(true){
int n=input.nextInt();
double p=input.nextDouble();
if(n==0&&p==0)
break;
System.out.println(String.format("%.0f", Math.pow(p, 1.0/n)));
}
}
}