用了暴力解法,果断超时,上网一搜,哇!!!
发现了解题神法:
这有详细解释:http://acm.hdu.edu.cn/discuss/problem/post/reply.php?postid=11661&messageid=1&deep=0
想不懂的去看看吧!
直接贴代码;
#include <stdio.h> #include <math.h> int main() { int i,j,k,t; int n,m; double result; scanf("%d",&n); while(n--) { result=0; scanf("%d",&m); for(i=1;i<=m;i++) { result+=(log10((double)i)); } printf("%d ",(int)result+1); } return 0; }