标签:public get stat int() pre ++ tin -o origin
代码实现如下:
import java.util.Scanner; public class Main { public static void main(String []args) { Scanner cin = new Scanner(System.in); int T = cin.nextInt(); for(int i = 0; i < T; i++) { int N = cin.nextInt(); System.out.println(Search(N)); } } static int Search(int N)//快速幂的模板一般都与下面的代码相同 { int ans = 1; int temp = N; while(N != 0) { if((N & 1) != 0) { ans = (ans%10)*(temp%10); } temp = (temp%10) * (temp%10); N = N>>1; } ans = ans%10; return ans; } }
标签:public get stat int() pre ++ tin -o origin
原文地址:https://www.cnblogs.com/674001396long/p/10013223.html