用高精度计算出 S1!2!3!⋯n!n≤50。其中!表示阶乘定义为 n!n×(n−1)×(n−2)×⋯×1。例如5!5×4×3×2×1120。输入格式一个正整数 n。输出格式一个正整数 S表示计算结果。输入输出样例输入 #1复制3输出 #1复制9说明/提示【数据范围】对于 100% 的数据1≤n≤50。我第一次是这样写的#includebits/stdc.husing namespace std;int a[10];int main(){ios::sync_with_stdio(false);cin.tie(0);int n;cinn;int sum1,ans0;for(int i1;in;i){sum1; // 每次重新初始化阶乘for(int j1;ji;j){ sum*j; // 算出 i! }anssum; // 累加进总和}coutans;return 0;}提交半天发现满分不了才发现是这样写的#includebits/stdc.husing namespace std;int jiecheng[300];int he[300];void chengfa(int cnt){int jinwei0;for(int i1;ijiecheng[0];i){int tempjiecheng[i]*cntjinwei;jiecheng[i]temp%10;jinweitemp/10;}if(jinwei0){while(jinwei0){jiecheng[jiecheng[0]]jinwei%10;jinwei/10;}}}void jiafa(){int jinwei0;int lenmax(he[0],jiecheng[0]);for(int i1;ilen;i){int temphe[i]jiecheng[i]jinwei;he[i]temp%10;jinweitemp/10;}he[0]len;if(jinwei0){he[he[0]]jinwei;}}int main(){ios::sync_with_stdio(false);cin.tie(0);int n;cinn;jiecheng[0]1;jiecheng[1]1;he[0]0;for(int i1;in;i){if(i1){chengfa(i);}jiafa();}for(int ihe[0];i1;i--){couthe[i];}return 0;}位数太大就用数组来存这种方法可以突破160的阶乘原来用几个long都存不下lol