HDU ACMSteps 2.3.2 BigNumber

数学公式 log(10) n! = log 1 + log 2 + …… + log n 就能求出位数了,取下限

表示第一次用JAVA,勿喷~

 1 import java.util.Scanner;
 2 
 3 
 4 public class Main {
 5     public static void main(String[] args)
 6     {
 7         Scanner sc = new Scanner (System.in);
 8         int test;  test = sc.nextInt();
 9         int n;
10         for(int rd = 0; rd != test; ++rd)
11         {
12             n = sc.nextInt();
13             double res = 1;
14             for(int i = 1; i <= n; ++i)
15                 res += Math.log10(i);
16             int tmp = (int) Math.floor(res);
17             
18             System.out.println("" + tmp);
19             
20         }
21         sc.close();
22     }
23 }
View Code

 

posted on 2014-06-29 16:16  码农之上~  阅读(160)  评论(0编辑  收藏  举报

导航