hdu 1018 Stirling 求階乘位數

#include <iostream>
#include <cmath>
#define p acos(-1)
#define e exp(1)
#define f(n) ((0.5 * log(2 * p * n) + n * log(n) - n)/log(10))
using namespace std;
int main()
{
	int t, n;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		int ans = (int)f(n) + 1;
		printf("%d\n", ans);
	}
	return 0;
}

發佈了58 篇原創文章 · 獲贊 9 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章