1061 Rightmost Digit
来源:互联网 发布:mysql的having max函数 编辑:程序博客网 时间:2024/06/01 07:24
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
void main()
{
int i,j,t,x,a,n;
__int64 m,k,cache[10];
for(cin>>a;a!=0;a--)
{
cin>>n;
for(m=n%10,k=1,t=0,i=0;;i++)
{
x=1;
k=(k*m)%10;
for(j=0;j<t;j++)
{
if(k==cache[j])
{
x=0;
break;
}
}
if(x) cache[t++]=k;
else break;
}
if(n%t==0)
cout<<int (cache[t-1])<<endl;
else
cout<<int (cache[n%t-1])<<endl;
}
}
#include<cstdio>
#include<cstring>
using namespace std;
void main()
{
int i,j,t,x,a,n;
__int64 m,k,cache[10];
for(cin>>a;a!=0;a--)
{
cin>>n;
for(m=n%10,k=1,t=0,i=0;;i++)
{
x=1;
k=(k*m)%10;
for(j=0;j<t;j++)
{
if(k==cache[j])
{
x=0;
break;
}
}
if(x) cache[t++]=k;
else break;
}
if(n%t==0)
cout<<int (cache[t-1])<<endl;
else
cout<<int (cache[n%t-1])<<endl;
}
}
- 1061 Rightmost Digit
- HDU 1061 Rightmost Digit
- HDOJ 1061: Rightmost Digit
- hdu 1061 Rightmost Digit
- (hdu 1061)Rightmost Digit
- HDU 1061 Rightmost Digit
- hdoj 1061Rightmost Digit
- HDOJ 1061 Rightmost Digit
- 1061 Rightmost Digit
- HDU 1061 Rightmost Digit
- HDOJ 1061 Rightmost Digit
- hdoj 1061 Rightmost Digit
- hdu rightmost digit 1061
- HDU 1061 Rightmost Digit
- HDOJ 1061 - Rightmost Digit
- HDU 1061 Rightmost Digit
- hdu 1061 Rightmost Digit
- HDU 1061 Rightmost Digit
- 2008 October 16th Thursday (十月 十六日 木曜日)
- 1049 Climbing Worm
- 1050 Moving Tables
- 2008 October 17th Friday (十月 十七日 金曜日)
- 严重: IOException while loading persisted sessions: java.io.EOFException
- 1061 Rightmost Digit
- 1071 The area
- 1085 Holding Bin-Laden Captive!
- 2008 October 20th Monday (十月 二十日 月曜日)
- 1086 You can Solve a Geometry Problem too
- 1108 最小公倍数
- 2008 October 21th Tuesday (十月 二十一日 火曜日)
- 1115 Lifting the Stone
- Objective-C