tu_huang_di @ 2023-03-31 21:24:04
#include<iostream>
using namespace std;
int main()
{
long long s,n,i,j,t;
cin>>n;
for(i=1;i<=n;i++)
{
t=1;
for(j=1;j<=i;j++)
t*=j;
s+=t;
}
cout<<s;
}
以上程序只有50分
by Ice_lift @ 2023-03-31 21:26:35
@sunyuchen1 注:高精度
by tu_huang_di @ 2023-03-31 21:34:16
什么意思
by moli0518_qwq @ 2023-03-31 21:48:11
@sunyuchen1 高精度你开longlong都AC不了,50分很好了
by xxc123 @ 2023-04-10 22:16:27
求关注
#include<iostream>
using namespace std;
int a[1001],b[1001];
void add()
{
int t=0;
for(int i=1000;i>=1;i--)
{
b[i]=b[i]+a[i]+t;
t=b[i]/10;
b[i]%=10;
}
}
void multiplication(int x)
{
int t=0;
for(int i=1000;i>=1;i--)
{
a[i]=a[i]*x+t;
t=a[i]/10;
a[i]%=10;
}
}
void print()
{
int flag=0;
for(int i=1;i<=1000;i++)
{
if(b[i]!=0) flag=1;
if(flag) cout<<b[i];
}
}
int main()
{
a[1000]=b[1000]=1;
int n;
cin>>n;
for(int i=2;i<=n;i++)
{
multiplication(i);
add();
}
print();
return 0;
}
从末尾算,a是阶乘积,s是和
by xxc123 @ 2023-04-10 22:16:36
@sunyuchen1
by tu_huang_di @ 2023-04-14 19:32:59
@xxc123 已过谢谢