题目:输入两个整数x,y,要求输出x的y次方的结果的最后三位数(y<100).
1 import java.util.Scanner; 2 3 public class Main{ 4 5 public static void main(String[] args) { 6 Scanner sca = new Scanner(System.in); 7 int x = sca.nextInt(); 8 int y = sca.nextInt(); 9 int re=1; 10 11 for(int i=0;i<y;i++){ 12 re = re*x; 13 if(re/1000>=1){ 14 re = re%1000; 15 } 16 } 17 String str = String.valueOf(re); 18 if(str.length()==1){ 19 System.out.println("00"+str); 20 }else if(str.length()==2){ 21 System.out.println("0"+str); 22 }else { 23 System.out.println(str); 24 } 25 } 26 }