Fork me on GitHub

NYOJ题目28大数阶乘

-------------------------------------
祭出BigInteger

 

AC代码:

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc=new Scanner(System.in);
        
        int n=sc.nextInt();
        
        BigInteger ans=fac(n);
        System.out.println(ans);
        
    }
    
    
    public static BigInteger fac(int n){
        BigInteger res=BigInteger.valueOf(n);
        while(--n>1) res=res.multiply(BigInteger.valueOf(n));
        return res;
    }
}

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=28

posted @ 2016-10-23 00:13  CC11001100  阅读(175)  评论(0编辑  收藏  举报