首页 > 代码库 > NYOJ题目112指数运算

NYOJ题目112指数运算

技术分享

------------------------

 

好水啊....

 

AC代码:

 1 import java.io.BufferedReader; 2 import java.io.IOException; 3 import java.io.InputStreamReader; 4 import java.math.BigInteger; 5  6 public class Main { 7  8     public static void main(String[] args) throws IOException { 9         10         BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));11         12         boolean first=true;13         while(first || reader.ready()){14             first=false;15             String ss[]=reader.readLine().split(" ");16             BigInteger ans=pow(Integer.parseInt(ss[0]),Integer.parseInt(ss[1]));17             System.out.println(ans.toString());18         }19     }20     21     public static BigInteger pow(int a,int b){22         BigInteger res=BigInteger.ONE;23         for(int i=0;i<b;i++) res=res.multiply(BigInteger.valueOf(a));24         return res;25     }26     27 }

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=112

NYOJ题目112指数运算