|
沙发
楼主 |
发表于 2020-2-2 16:47:09
|
只看该作者
- #include<iostream>
- using namespace std;
- const int mm=100;
- int s[mm],a[mm],i,p,x,n;
- int main()
- {
- cin>>n;
- for(p=1; p<=mm-1; p++) a[p]=s[p]=0;
- a[0]=s[0]=1;
- for (i=2; i<=n; i++)
- {
- ///cheng
- for (p=0; p<=mm-1; p++) a[p]*=i;
- for (p=0; p<=mm-2; p++)
- {
- x=a[p];
- a[p]=x%10;
- a[p+1]+=x/10;
- }
- ///jia
- for (p=0; p<=mm-1; p++) s[p]+=a[p];
- for (p=0; p<=mm-2; p++)
- {
- x=s[p];
- s[p]=x%10;
- s[p+1]+=x/10;
- }
- }
- ///shuchu
- p=mm-1;
- while (s[p]==0 && p>0) p--;
- for (; p>=0; p--) cout<<s[p];return 0;
- }
复制代码 |
|