Yxy137 @ 2024-02-15 21:40:02
#include<bits/stdc++.h>
using namespace std;
long long a=1,ans=0;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
a=1;
for(int j=1;j<=i;j++){
a*=j;
}
ans+=a;
}
cout<<ans;
}
by xiangzhenze611 @ 2024-02-15 21:42:52
@Yxy137
n \le 50
要用高精度
by xiangzhenze611 @ 2024-02-15 21:43:44
@Yxy137 long long
存不下
by Tubishu @ 2024-02-16 17:18:14
@Yxy137 n太大的时候long long 也存不下了,考虑字符串吧
by Abelxxyy @ 2024-02-20 19:11:15
可以试试double
.