杭电acm1061
这最后一个数只是最后个位数反复相乘的结果,而这结果只在0与9之间,我们只要计算出它的循环
长度即可。
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
while (n--)
{
int m;
cin>>m;
int a[10][5]={
{0,0,0,0,0},
{1,1,1,1,1},
{6,2,4,8,6},
{1,3,9,7,1},
{6,4,6,4,6},
{5,5,5,5,5},
{6,6,6,6,6},
{1,7,9,3,1},
{6,8,4,2,6},
{1,9,1,9,1}};
cout<<a[m%10][m%4]<<endl;
}
return 0;
}