题目描述:
源码:
#include"iostream" #include"cmath" using namespace std; #define PI 3.1415926 #define E 2.718281828459045 int main() { int n, num; double sum; cin>>n; for(int i = 0; i < n; i++) { cin>>num; // sum = 0; // for(int i = 1; i <= num; i++) // sum += log10(i); //下面的一行代码等价于上面的注释 sum = log10(sqrt(2*PI*num)) + num * log10(num/E);//斯特林公式 cout<<(int)sum+1<<endl; } return 0; }