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 |
Re:700多ms过的 用公式可以0ms飘过 那样就更水了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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator