您的位置:首页 > 理论基础 > 计算机网络

找规律。。&&http://acm.hdu.edu.cn/showproblem.php?pid=1097

2012-01-07 10:39 591 查看
#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: