HDU 1042--N! 【大数】
发布时间:2020-12-14 02:27:33 所属栏目:大数据 来源:网络整理
导读:N! Time Limit: 10000/5000 MS (Java/Others)????Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 65214????Accepted Submission(s): 18651 Problem Description Given an integer N(0 ≤ N ≤ 10000),your task is to calculate N! ? In
N!Time Limit: 10000/5000 MS (Java/Others)????Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 65214????Accepted Submission(s): 18651
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
?
Sample Output
?
大数水题,跟着大一的再做一遍。 #include <cstdio> #include <cstring> int a[110000]; int main (){ int n; while(scanf("%d",&n)!=EOF){ int d = 1; int c; memset(a,sizeof(a)); a[1] = 1; for(int i = 1; i <= n; ++i){ c = 0; for(int j = 1; j <=d; ++j){ a[j] = a[j] * i + c; c = a[j] / 10; a[j] = a[j] %10; } while(c){ a[++d] = c % 10; c=c/10; } } for(int i = d; i >= 1; --i) printf("%d",a[i]); printf("n"); } return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |