加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

杭电1018 (大数阶乘位数)

发布时间:2020-12-14 03:35:57 所属栏目:大数据 来源:网络整理
导读:#include stdio.h#include math.h#define PI 3.1415926/* 现由斯特林[stirling]公式可得: lnN!= NlnN-N+0.5ln(2N*pi)而10的7次方阶乘的位数等于: log10(N!)取整后加1 log10(N!)=lnN!/ln(10)*/int main (){int t,n;scanf ("%d",t);while (t--){scanf ("%d"
#include <stdio.h>
#include <math.h>
#define PI 3.1415926
/*
   	现由斯特林[stirling]公式可得: 
    	lnN!= NlnN-N+0.5ln(2N*pi)
	而10的7次方阶乘的位数等于: 
	log10(N!)取整后加1 
	log10(N!)=lnN!/ln(10)
*/
int main (){
	int t,n;
	scanf ("%d",&t);
	while (t--){
		scanf ("%d",&n);
		int d = ceil ((n*log((double)n)-n+log (2.0*(double)n*PI)/2) / log (10.0));
		if (d==0) d++;
		printf ("%dn",d);
	}
	return 0;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读