杭电oj2035(JAVA

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner scanner=new Scanner(System.in);
	while (scanner.hasNext()){
		int a=scanner.nextInt()%1000;//直接取后三位,方便后续高效运算
		int b=scanner.nextInt();
		if (a==0&&b==0) {
			break;
		}
		int x=1;
		for (int i = 1; i <= b; i++) {
			x=x*a%1000;//每次运算都取后三位
		}
		System.out.println(x);
	}
	}
}

猜你喜欢

转载自blog.csdn.net/Gluskin/article/details/120996974