标签:des style blog class code c
Time Limit: 2000/1000 MS
(Java/Others) Memory Limit: 65536/32768 K
(Java/Others)
Total Submission(s): 30543 Accepted
Submission(s): 11624
1 /************************************************** 2 HDOJ 1061 已经AC 3 ***************************************************/ 4 #include <iostream> 5 using namespace std; 6 int main() 7 { 8 int N,T; 9 int round=0; 10 int r[100]={0}; 11 int i=0; 12 cin>>T; 13 while(T--) 14 { 15 cin>>N; 16 r[1]=N%10;//一定要对其求余 17 r[2]=(N%10)*(N%10)%10;//求余后再相乘,然后再求余,因为如果直接相乘时碰到1000000000时会发生错误 18 for(i=3;;i++) 19 { 20 r[i]=r[i-1]*(N%10)%10; 21 if(r[i]==r[1]) 22 {round=i-1;break;} 23 } 24 if(N%round==0) 25 cout<<r[round]<<endl; 26 else cout<<r[N%round]<<endl; 27 } 28 //while(1); 29 return 0; 30 }
HDOJ 1061 Rightmost Digit,布布扣,bubuko.com
标签:des style blog class code c
原文地址:http://www.cnblogs.com/kb342/p/3734416.html