国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設(shè)計 > 正文

hdu1042【大數(shù)階乘】

2019-11-11 01:50:22
字體:
供稿:網(wǎng)友

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

大數(shù)的階乘,10000的階乘為35000多位數(shù)。 開個3000的數(shù)組,數(shù)組里的每個數(shù)儲存13位數(shù),就足夠了 這算是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"); }}
上一篇:1078. Hashing (25)

下一篇:格子中輸出

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 西乡县| 张家界市| 本溪市| 嘉黎县| 乌鲁木齐市| 额敏县| 苏尼特左旗| 永兴县| 楚雄市| 公安县| 蚌埠市| 巴东县| 区。| 乌恰县| 宁陕县| 合江县| 临高县| 石棉县| 兴文县| 北安市| 武平县| 肥乡县| 武定县| 运城市| 衡阳市| 青田县| 扶沟县| 历史| 宿松县| 启东市| 宁远县| 潢川县| 庆云县| 凭祥市| 来凤县| 喀喇沁旗| 宣恩县| 吉木萨尔县| 奉化市| 贺州市| 平塘县|