Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:不tle才怪

Posted by 2012 at 2010-08-28 16:32:37 on Problem 2551 and last updated at 2010-08-28 16:33:05
In Reply To:很奇怪的一个问题,咋相差就这么大 16MS VS TLE Posted by:dynamic_study at 2009-08-20 17:35:53
> TLE:
> #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;
> }
不tle才怪呢    s%=n 跟 s%n一样???

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator