http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1004
思路:其实就是求(n^n)%10的值。。直接用快速幂。
#include<iostream>
#include<stdio.h>
using namespace std;
int n;
int quick(int n1)
{
int temp=1,temp1=n%10;
while(n1)
{
if(n1&1) temp=(temp*temp1)%10;
temp1=(temp1*temp1)%10;
n1=n1/2;
}
return temp;
}
int main()
{
scanf("%d",&n);
printf("%d\n",quick(n));
}