liu_le_chen @ 2023-08-03 21:41:40
#include<bits/stdc++.h>
using namespace std;
long long n,cnt=1,s;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
cnt*=j;
}
s+=cnt;
cnt=1;
}
cout<<s;
return 0;
}
by ybc2025chenyuyang @ 2023-08-03 21:44:03
嗯,这题要用高精,或者是用Py
by _Fancy_ @ 2023-08-03 21:44:39
@liulechen 或者开int128
by liu_le_chen @ 2023-08-03 21:48:32
大佬帮忙改一下好吗?
by ybc2025chenyuyang @ 2023-08-03 21:54:02
int128只有50分,所以还是要用高精度或派森
by ybc2025chenyuyang @ 2023-08-03 21:54:53
建议lz先学一下高精度再来做此题
by ybc2025chenyuyang @ 2023-08-03 21:57:24
不对,int128有75分
by liu_le_chen @ 2023-08-03 21:57:44
其实已经学完了高精度了,不过这题不知道怎么用
by kunkun123456 @ 2023-08-06 16:22:03
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> jia(vector<int>a, vector<int>b )
{
vector<int> ans;
if(a.size()<b.size()) swap(a,b);
int t=0;
for(int i=0;i<a.size();i++)
{
t+=a[i];
if(i<b.size()) t+=b[i];
ans.push_back(t%10);
if(t>=10) t=1;
else t=0;
}
if(t) ans.push_back(t);
return ans;
}
vector<int> mul(vector<int> a,int b)
{
vector<int> res;
for (int i = 0; i < a.size(); i++)
a[i] *= b;
int t = 0;
for (int i = 0; i < a.size(); i++)
{
t += a[i];
res.push_back(t%10);
t /= 10;
}
while (t) res.push_back(t%10), t /= 10;
while (res.size() > 1 && res.back() == 0) res.pop_back();
return res;
}
vector<int> func(int a)
{
vector<int> ans;
ans.push_back(1);
for(int i=1;i<=a;i++)
{
ans=mul(ans,i);
}
return ans;
}
int main()
{
cin>>n;
vector<int> ans;
ans.push_back(0);
for(int i=1;i<=n;i++)
{
ans=jia(ans,func(i));
}
for(int i=ans.size()-1;i>=0;i--)
{
cout<<ans[i];
}
}
by kunkun123456 @ 2023-08-06 16:24:40
可以直接抄
快感谢我
by kunkun123456 @ 2023-08-06 16:33:49
对了,我大号叫shabi12345,被黑客改成这个名字,黑客在我电脑上发言被禁了,如果管理员能看见,能把禁言解除吗