big number time limit :20000/10000 ms (Java/others ) memory limit :65536/32768 k (Java/others ) totalsubmision ) s
problemdescriptioninmanyapplicationsverylargeintegersnumbersarerequired.someoftheseapplicationsareusingkeysforsecuretransmisetransmismismised etc.inthisproblemyouaregivenanumber,youhavetodeterminethenumberofdigitsinthefactorialofthenumber。
inputinputconsistsofseverallinesofintegernumbers.thefirstlinecontainsanintegern,whichisthenumberofcasestobested,Follower
Output
theoutputcontainsthenumberofdigitsinthefactorialoftheintegersappearingintheinput。
样品输入21020
样品输出719
Source Asia 2002,Dhaka,Bengal
读我
第一个代码是求n! 计算阶乘的位数,要求给出位数,取对数后,最后求出1;
第二个代码使用stirling表达式求解n! # include iostream # includecmathusingnamespacestd; int main () { int n,a; cinn; wile(n----) { cina; 双尾sum=0; for(intI=1; i=a; I () sum=log10 ) I; }cout(int ) ) sum )1endl; } return 0; () ) ) ) )。
# include iostream # includecmathusingnamespacestd; int main () doublepi=ACOS ) double(-1 ); 获取//pi的值,并对-1取反余弦函数。 doublee=exp(double(1); //取得自然底数e的值,使用stirling式,求出n! 请参阅。 int T,a; cinT; double ans; wile(t----) { ans=0; cina; ans=0.5*log10(2.0*a*pi ) a* ) log10 () a )-log10(e ) ); cout(int ) ans 1endl; } return 0; () ) ) ) )。