斯特林公式(Stirling's approximation)
求位数
代码
#include<iostream> #include<cmath> using namespace std; #define pi 3.1415926535 #define e 2.718281828459 int main() { int n; cin >> n; printf("%d",(int)(1 + 0.5*log10(2 * pi*n) + n*log10(n / e))); }
求位数
#include<iostream> #include<cmath> using namespace std; #define pi 3.1415926535 #define e 2.718281828459 int main() { int n; cin >> n; printf("%d",(int)(1 + 0.5*log10(2 * pi*n) + n*log10(n / e))); }