题意让求一个数m阶乘的位数,可以用sum(log10(1~n))+1打表,也可以用公式
#include <iostream> #include <math.h> using namespace std; const double e= 2.718281828459 ; const double pi= 3.1415926535898 ; int main() { long long n,tt; cin>>tt; while (tt>0) { tt--; cin>>n; long long ans = (long long)((double)log10(sqrt(2 * pi * n)) + n * log10(n / e))+1; cout<<ans<<endl; } return 0; }