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:根据stirling来做In Reply To:Re:这样也tle 郁闷!!!怎么能不超时阿!! Posted by:first at 2003-12-13 19:17:19 > #include <iostream> > using namespace std; > void main() > { > long double ans; > int n,times,i,digits; > cin>>times; > while(times--) > { > cin>>n; > ans=1.0; > digits=0; > for(i=2;i<=n;i++) > { > ans*=i; > if(ans>=10000000.0) > { > digits+=7; > ans/=10000000.0; > } > else if(ans>=1000000.0) > { > digits+=6; > ans/=1000000.0; > } > else if(ans>=100000.0) > { > digits+=5; > ans/=100000.0; > } > else if(ans>=10000.0) > { > digits+=4; > ans/=10000.0; > } > else if(ans>=1000.0) > { > digits+=3; > ans/=1000.0; > } > else if(ans>=100.0) > { > digits+=2; > ans/=100.0; > } > else if(ans>=10.0) > { > digits+=1; > ans/=10.0; > } > > } > digits++; > cout<<digits<<endl; > } > > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator