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

来源:互联网 发布:域名whois查询工具 编辑:程序博客网 时间:2024/06/08 18:41
#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;}

原创粉丝点击