码迷,mamicode.com
首页 > 其他好文 > 详细

hdu1042 N!(大数)

时间:2016-08-08 17:41:20      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

N!

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 75069    Accepted Submission(s): 21870


Problem Description
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!
 


Input
One N in one line, process to the end of file.
 


Output
For each N, output N! in one line.
 


Sample Input
1 2 3
 


Sample Output
1 2 6
 


Author
JGShining(极光炫影)
 


Recommend
We have carefully selected several similar problems for you:  1715 1047 1063 1753 1316 
 


Statistic | Submit | Discuss | Note

java大法好~~~

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sca=new Scanner(System.in);
		BigInteger res[]=new BigInteger[10000+10];
		res[0]=BigInteger.ONE;
		for(int i=1;i<10000+1;i++){
			res[i]=res[i-1].multiply(BigInteger.valueOf(i));
		}
		while(sca.hasNext()){
			int x=sca.nextInt();
			System.out.println(res[x]);
		}
	}

}



hdu1042 N!(大数)

标签:

原文地址:http://blog.csdn.net/su20145104009/article/details/52153784

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!