14:求10000以内n的阶乘
14:求10000以内n的阶乘
- 查看
- 提交
- 统计
- 提问
总时间限制: 5000ms 内存限制: 655360kB描述
求10000以内n的阶乘。
输入只有一行输入,整数n(0<=n<=10000)。输出一行,即n!的值。样例输入
100样例输出
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000来源JP06
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstring> 5 using namespace std; 6 int a[1000001]={1}; 7 int ans[10000001]={1}; 8 char n[1001]; 9 int en[1001]; 10 int main() 11 { 12 int n; 13 cin>>n; 14 int lans=1; 15 int x=0; 16 for(int i=1;i<=n;i++) 17 { 18 19 for(int j=0;j<lans;j++) 20 { 21 a[j]=a[j]*i+x; 22 x=a[j]/10; 23 if(x>0&&j==lans-1) 24 lans++; 25 a[j]=a[j]%10; 26 } 27 } 28 int flag=0; 29 for(int i=lans;i>=0;i--) 30 { 31 if(a[i]==0&&flag==0) 32 continue; 33 else flag=1; 34 cout<<a[i]; 35 } 36 return 0; 37 }
相关推荐
nurvnurv 2020-02-25
SciRui 2020-01-31
风和日丽 2020-01-02
tvk 2019-12-28
seekerhit 2019-12-05
xw0 2019-09-06
85274852 2012-04-29
ivabrother 2018-05-07
一两银子 2017-04-03
amazingbo 2019-04-29
83427718 2009-07-15
yueloveme 2013-05-30
samsai00 2008-05-16
81540398 2010-06-22
wujimiao 2019-01-21
AStudystudy 2007-11-24
fundebug 2019-03-29
BAT 批处理程序 2017-06-20