51nod_1057 N的阶乘(大数)

来源:互联网 发布:php如何解决高并发问题 编辑:程序博客网 时间:2024/06/07 22:16

1057 N的阶乘
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题

输入N求N的阶乘的准确值。
Input
输入N(1 <= N <= 10000)
Output
输出N的阶乘
Input示例
5
Output示例
120

思路:java暴力

代码:

//package javaBigInt;import java.math.BigInteger;import java.util.Scanner;public class theFactor_of_N {    public static void main(String[] args){        Scanner cin=new Scanner(System.in);        int n=cin.nextInt();        int t=n;        BigInteger res=new BigInteger("1");        for(int i=2;i<=n;i++ ){            String tp=""+i;            BigInteger res1=new BigInteger(tp);            res=res.multiply(res1);        }        System.out.println(res);    }}
0 0
原创粉丝点击