1061 N^N

#include <iostream>
using namespace std;
int main()
{int n,m,s,t,i;
cin>>n;
while(n--)           
{s=1;
cin>>m; //               2  4 8 6 2
t=(m-1)%4;//4个一循环    3  9 7 1 3
m=m%10;  //              4  6 4 6 4
for(i=1;i<=t+1;i++) //   5  5 5 5 5    t+1避免m%4=0
s*=m;    //              6  6 6 6 6
cout<<s%10<<endl;} //    7  9 3 1 7
return 0;}//             8  4 2 6 8

你可能感兴趣的:(1061 N^N)