Bramble_Marshall @ 2023-10-06 20:33:21
#include <bits/stdc++.h>
using namespace std;
const int N=505;
int na[N], nb[N];
string add(string a, string b) {
string ans="";
int la = a.size(), lb = b.size();
int m = max(la, lb);
for (int i = 0; i < la; i++) na[la-i-1]=a[i]-'0';
for (int i = 0; i < lb; i++) nb[lb-i-1]=b[i]-'0';
for (int i = 0; i < m; i++) na[i]+=nb[i],na[i+1]+=na[i]/10,na[i]%=10;
if (!na[m] && m>0) m--;
for (int i=m; i>=0; i--) ans+=na[i]+'0';
return ans;
}
string move(long long iut) {
string ans = to_string(iut);
return ans;
}
long long fact(int iut) {
long long ans = 1;
while(iut != 0) {
ans *= iut;
iut--;
}
return ans;
}
int main() {
int n;
cin >> n;
string ans, iut;
for(int i = 1; i <= n; i++) {
ans = add(ans, move(fact(i)));
}
cout << ans;
system("pause");
return 0;
}
by xzq4121 @ 2023-10-06 21:05:54
a=int(input())
d=1
e=0
for b in range(1,a+1):
for c in range(1,b+1):
d=d*c
e=e+d
d=1
print(e)
其实可以用python.
by xzq4121 @ 2023-10-06 21:06:40
python自带高精
by 99999873654as7829 @ 2023-10-18 09:55:01
输出变量,看看哪里错的,多次输出变量可以调试程序。