首页 > 编程知识 正文

stirling university,stirling公式证明

时间:2023-05-05 17:59:45 阅读:186476 作者:404

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; () ) ) ) )。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。