yang1812 @ 2023-11-08 21:52:04
#include<bits/stdc++.h>
using namespace std;
int a[120],b[120],n;
void add(int *a , int *b){
for(int i = 1;i <= 120;i++){
int c;
b[i] += a[i] + c;
c = b[i] / 10;
b[i] %= 10;
}
}
void cheng(int *a , int c){
for(int i = 1;i <= 120;i++){
int b;
a[i] *= c + b;
c = a[i] / 10;
a[i] %= 10;
}
}
int main(){
scanf("%d",&n);
a[1] = 1;
for(int i = 1;i <= n;i++){
cheng(a , i);
add(a , b);
}
bool flag = 0;
for(int i = 120;i >= 1;i--){
if(b[i] != 0){
flag = 1;
}
if(flag){
printf("%d",b[i]);
}
}
return 0;
}
by TT666_ @ 2023-11-17 18:58:14
using namespace std;
int main() {
int n = 1;
int i = 1;
int x;
int sum = 0;
cin >> x;
while ( i <= x )
{
n = n*i;
i++;
sum = sum + n;
}
cout << sum;
return 0;
}
自己对一下```cpp