N!
来源:互联网 发布:农网改造包工怎么算法 编辑:程序博客网 时间:2024/04/28 14:31
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
123
Sample Output
126
此题主要是解决在a.multiply(i)再mulitply()中不能够用整形,必须是大整形所以可以改为multiply(new BigInteger(""+i) );
import java.util.*;import java.io.*;import java.math.*;public class Main{ static BigInteger[] ans;//注意定义大数的数组的放法再BigInteger后边加上数组的符号[].public static void main(String[] args){Scanner cin=new Scanner(System.in);//BigInteger i;int i,n;ans=new BigInteger[10010];ans[0]=BigInteger.valueOf(1);ans[1]=BigInteger.valueOf(1);ans[2]=BigInteger.valueOf(2);for(i=3;i<=10001;i++){ans[i]=ans[i-1].multiply(new BigInteger(""+i) );}while(cin.hasNext()){n=cin.nextInt();System.out.println(ans[n]);}}}
0 0
- N!
- N!
- n
- N
- N!
- N!
- N!
- N!
- n!
- N!
- N!
- N!
- N!
- n
- N!
- N!
- N!
- n!
- 本地 push 到github 每次都需要输入用户密码问题
- 使用SlickEdit2013 来创建带有makefile文件的工程
- c++ primer 学习之路 二 —— 实验楼作业笔记(1-3)
- 查询各个部门的部门号,部门名,部门人数及部门平均工资
- 数据结构:堆排序算法的实现
- N!
- mysql(八、触发器)
- 竖式问题
- tomcat8配置全局数据源
- stl中map和hash_map底层实现详解
- 日经春秋 20151002
- 黑马程序员-----GUI
- centos 图形 命令行 界面切换
- Linux 进程管理(一)