fujunye12345 @ 2024-12-11 17:21:05
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
long long t=1,s=0;
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
t*=j;
s+=t,t=1;
}
cout<<s;
return 0;
}
by jomify @ 2024-12-11 21:24:21
long long在n=50时会溢出
by fujunye12345 @ 2024-12-12 13:46:30
@jomify那要怎么改?
by jomify @ 2024-12-12 15:45:39
@fujunye12345 需要高精度计算的相关知识和方法
by fujunye12345 @ 2024-12-12 17:43:00
@jomify谢谢