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:700多ms过的 用公式可以0ms飘过 那样就更水了

Posted by 980616701 at 2009-05-31 09:26:48 on Problem 1423
In Reply To:晕倒! 985Ms过的!有什么好的方法? Posted by:bailing_0105 at 2008-07-06 12:38:41
#include<stdio.h>
int main()
{
	int n,m,i,bit=1;
	double num=0;
	scanf("%d",&n);
	while(n--)
	{
		bit=1,num=1;
		scanf("%d",&m);
		for(i=2;i<=m;i++)
		{
			num*=i;
			if(num<10){continue;}
			if(num<100){num/=10;bit+=1;continue;}
			if(num<1000){num/=100;bit+=2;continue;}
			if(num<10000){num/=1000;bit+=3;continue;}
			if(num<100000){num/=10000;bit+=4;continue;}
			if(num<1000000){num/=100000;bit+=5;continue;}
			if(num<10000000){num/=1000000;bit+=6;continue;}
			if(num<100000000){num/=10000000;bit+=7;continue;}
		}
		printf("%d\n",bit);
	}
	return 0;
}

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