【大数问题】 HDOJ 1042 N!

java做很轻松。。。

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

public class Main
{
	public static void main(String[]args){
		Scanner scanner = new Scanner(System.in);
		BigInteger  ans;
		int n;
		while(scanner.hasNextInt()) {
			n = scanner.nextInt();
			ans = BigInteger.ONE;
			for(int i = 2; i <= n; i++) ans = ans.multiply(BigInteger.valueOf(i));
			System.out.println(ans);
		}
	}
}


你可能感兴趣的:(HDU)