求10^7以内的数的阶乘位数= =。。 以前看过好多次 都没思路。。。今天百度了,纠结了!数学如此神奇,膜拜膜拜。。。。 #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string.h> #include <math.h> using namespace std; int main(void) { int ncases,n; scanf("%d",&ncases); while( ncases-- ) { scanf("%d",&n); double sum = 0; for(int i=1; i<=n; i++) sum += log10(i); // Magic ~! Math is so magical! int x = int(sum)+1; // Although using int to exchange double has a little bug , but accepted , faint > <! printf("%d/n",x); } return 0; }