题目链接:http://codeforces.com/contest/742/problem/A
【中文题意】求1378^nMOD(10)之后的值是多少。
【思路分析】直接快速幂就可以了。
【AC代码】
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define MOD 10
int n;
int quick_power(int a,int b)
{
int ans=1;
while(b)
{
if(b&1)
{
ans=ans*a;
ans%=MOD;
}
b/=2;
a=a*a%MOD;
}
return ans%10;
}
int main()
{
while(~scanf("%d",&n))
{
printf("%d\n",quick_power(1378,n));
}
return 0;
}