BJFU 1005——Factorial of large numbers
来源:互联网 发布:小斯在以色列的数据 编辑:程序博客网 时间:2024/06/06 07:18
描述
Factorial, as we all know, is the product of all the positive integers from one up to and including a given integer. For example, factorial zero is assigned the value of one; factorial four is 1 × 2 × 3 × 4. Symbol: N! The N is the given integer. But it is hard to calculate the factorial when the N is large. Ben wrote a program to calculate N!(N<10000) when he was in grade one. So try it!
输入
The input consists of multiple test cases. One N (0<=N<=10000,integer) in a line for each test case. Process to the end of file.
输出
For each test case, print the value of N! in a single line.
样例输入
5
10
20
100
样例输出
120
3628800
2432902008176640000
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
这道题的大意是输入一个数,输出它的阶乘。
看到这个栗子,明显是大数高精度运算,嘿嘿,还好在刘汝佳的书上看见过。
把书中算法改造一下后交了一次TLE,T_T,被坑了一回。
之后还是看了一位大神的代码,恍然大悟,原来一个数组其实可以存一个比较大的数,而不是存0-9一位数,这样效率就大大提高了。
之后不断尝试一个数组存的位数为多少为最佳,奇怪的是当数组开到某一位时就WA了,至今还没搞明白。。。。
等下回实力高点再回头填坑算了。Orz.........
- BJFU 1005——Factorial of large numbers
- Factorial of large numbers bjfu1005 java实现大数阶乘
- random generator demo(Law of Large Numbers)
- WLLN(Weak Law of Large Numbers) DEMO
- Light—oj 1045 - Digits of Factorial
- BJFU 1002——九九乘法表
- BJFU 1004——Sudoku
- BJFU 1008——Average
- BJFU 1009——抽奖
- BJFU 1010——博弈
- BJFU 1012——素数
- BJFU 1001——整数求和
- BJFU 1006——排序输出
- BJFU 1025——Ackermann函数
- BJFU 1040——子块和
- BJFU 1069——格式化数字
- given stream of integers, find first 100 large numbers (!!!)
- poj1401——Factorial
- CentOS 7 下网卡重新命名
- Unique Paths
- CentOS 7 下安装音频编辑器Audacity
- LeetCode--Insert Interval
- 什么是GC?GC的工作原理如何?
- BJFU 1005——Factorial of large numbers
- 为什么 Android 截屏需要 root 权限
- 程序链接与装载
- 机器视觉学习笔记(一)
- CentOS 7 最小化安装后 没有安装ifconfig命令的解决方法
- 安装配置cuda6.5以及vs2012的环境
- boost.any实现任意类型存储
- Android开发之详解五大布局
- 传真服务器系统的架设方案