http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=12
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std ;
int arr [ 20 ] = { 1 , 4 , 7 , 6 , 5 , 6 , 3 , 6 , 9 , 0 , 1 , 6 , 3 , 6 , 5 , 6 , 7 , 4 , 9 , 0 } ;
int main ()
{
int n ;
while ( cin >> n )
{
int a ;
for ( int i = 0 ; i < n ; ++ i )
{
cin >> a ;
cout << arr [ a % 20 - 1 ] << endl ;
}
}
return 0 ;
}
#include<bits/stdc++.h>
using namespace std;
int pow(int n,int p)
{
int ans=1;
while(p)
{
ans%=10;//*******一定要先取模
n%=10;
if(p&1) ans*=n;
p>>=1;
n*=n;
}
return ans%10;
}
int main()
{
int i,j,k,ans,m,n,t,tt=0,tmp;
cin>>t;
while(t--)
{
cin>>n;
cout<<pow(n,n)<<endl;
}
return 0;
}