| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
很奇怪的一个问题,咋相差就这么大 16MS VS TLETLE:
#include<stdio.h>
#include<math.h>
int main()
{
int s;
int ans,n;
while(scanf("%d",&n)!=EOF)
{
s=1;
ans=1;
while(s%n!=0)
{
s=s*10+1;
ans++;
}
printf("%d\n",ans);
}
return 0;
}
AC,16MS:
#include<stdio.h>
#include<math.h>
int main()
{
int s;
int ans,n;
while(scanf("%d",&n)!=EOF)
{
s=1;
ans=1;
s%=n;
while(s)
{
s=s*10+1;
ans++;
s%=n;
}
printf("%d\n",ans);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator