hdu1042【大数阶乘】
来源:互联网 发布:淘宝官方app客户端下载 编辑:程序博客网 时间:2024/06/03 14:53
N!
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 79143 Accepted Submission(s): 23137
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
大数的阶乘,10000的阶乘为35000多位数。
开个3000的数组,数组里的每个数储存13位数,就足够了
这算是10万亿进制了吧233333
代码:
#include <iostream>#include <string>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <algorithm>#include <queue>#include <map>#define MST(s,q) memset(s,q,sizeof(s))#define INF 0x3f3f3f3f#define MAXN 9999using namespace std;long long a[10005][3001];void deal(){ MST(a, 0); a[0][1] = 1; for (int i = 1; i <= 10000; i++) { long long r = 0; for (int j = 1; j <= 3000; j++) { a[i][j] = a[i - 1][j] * i + r; if (a[i][j] < 0) printf("\n"); r = 0; if (a[i][j] > 10000000000000) { r = a[i][j] / 10000000000000; a[i][j] %= 10000000000000; } } }}int main(){ deal(); int n; while (cin >> n) { int i = 3000; while (a[n][i] == 0)i--; printf("%lld", a[n][i] ); // 刚开始不用补0 i--; for (; i >= 1; i--) printf("%013lld", a[n][i] ); // 不够13位就补0 printf("\n"); }}
0 0
- hdu1042大数阶乘
- hdu1042【大数阶乘】
- HDU1042 N! 大数阶乘 Java
- hdu1042 N! (高精度\大数阶乘)
- Hdu1042 JAVA版C版处理大数阶乘
- HDU1042 高精度阶乘
- hdu1042 大阶乘
- HDU1042(大数运算)
- hdu1042-N!(大数)
- hdu1042 N!(大数)
- hdu1042 N!_大数
- hdu1042 n! 大整数阶乘
- HDU1042 - N! (大数运算)
- HDU1042&1753--大数运算--JAVA
- 大数阶乘
- 大数阶乘。
- 大数阶乘
- ~阶乘~大数
- iOS AVAudioPlayer音频播放器
- Shiro学习详解
- Android之SDK、NDK、JNI和so文件
- Java 可变参数 使用
- 北理05年复试上机之实现日期类
- hdu1042【大数阶乘】
- C++函数详解
- JS之复制文章时自动在文章末尾加上来源网址
- java之通过Excel批量添加数据
- shell的date命令:使用方法,以及小时、分钟的计算
- 跟我学AngularJs:Directive指令用法解读(下)
- PHP Laravel method paginate cannot find
- 如何让 height:100%; 起作用
- shell 用变量接收 date -d 的时间