#include<iostream>
#include<string.h>
using namespace std;
int hash[10];
int main()
{ long long a,b;
int i;
while(cin>>a>>b)
{ memset(hash,0,sizeof(hash));
hash[0]=a%10;
for( i=1;i<11;++i)
{ hash[i]=(hash[i-1]*a)%10;
if(hash[i]==hash[0]) break;
}
b=b%i;
if(b) cout<<hash[b-1]<<endl;
else cout<<hash[i-1]<<endl;
}return 0;
}
找规律。。&&http://acm.hdu.edu.cn/showproblem.php?pid=1097
最新推荐文章于 2025-12-01 18:53:18 发布
本文介绍了一个模数转换算法的具体实现,通过使用哈希表记录幂次方运算结果的末位数字,来加速大数模数运算的过程。该算法能够有效地减少重复计算,提高运算效率。
1702

被折叠的 条评论
为什么被折叠?



