lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.
this puzzle describes that: gave a and b,how to know the a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.
import java.util.Scanner; public class test2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while (sc.hasNext()){ double a=sc.nextInt(); int b=sc.nextInt(); double d=a%10; double []c=new double[4]; for (int i = 0; i < c.length; i++) { c[i]=Math.pow(d,i+1); } if(b==0){ System.out.println(1); } else if (b%4==0) { System.out.println((int)(c[3]%10)); } else { System.out.println((int)(c[b%4-1]%10)); } } } }z怎么说呢千万不要落下这个幂的隐藏规律,就是只要管个位数字即可。。