HDOJ-ACM1018(JAVA)
题意:
求n!的位数,0<n<10^7
思路:log10(1)+log10(2)+···+log10(n) = log10(n!) 【题目的考点就在这吧】
解题:
import java.util.*; import java.io.*; public class Main{ public static void main(String[] arg){ Scanner scan = new Scanner(new BufferedInputStream(System.in)); int N=scan.nextInt(); while(N--!=0){ double count = 0; int n = scan.nextInt(); int len = n + 1; for(int i = 1 ; i != len ; i ++ ){ count = count + Math.log10(i); } System.out.println((int)(count+1)); } scan.close(); } }
让蔷薇开出一种结果~