momo36524 @ 2023-11-02 17:55:51
#include<stdio.h>
int main(void)
{
int use_for_multiple[1005]={0};
int result[1005]={0};
use_for_multiple[0]=result[0]=1;
int n,i,j,pointer;
scanf("%d",&n);
for(i=2;i<=n;i++){
for(j=0;j<=pointer;j++)
use_for_multiple[j]*=i;//完成阶乘
j=0;
do{
while(use_for_multiple[j]>9){//防止 use_for_multiple[j]>99的情况
use_for_multiple[j+1]+=(use_for_multiple[j]/10);
use_for_multiple[j]%=10;
}
++j; //顺带完成数位更新
} while(use_for_multiple[j]>0||j<=pointer);
j-=1;
pointer=j;
//每个i的阶乘再与reuslt相加
for(;j>=0;j--)
result[j]+=use_for_multiple[j];
}
j=0;
do{
while(result[j]>9){//防止 use_for_multiple[j]>99的情况
result[j+1]+=result[j]/10;
result[j]%=10;
}
j++; //顺带完成数位更新
} while(result[j]>0||j<=pointer);
j-=1;
for(;j>=0;j--)
printf("%d",result[j]);
return 0;
}
by 呆呆的她啊 @ 2023-11-02 18:07:58
让我先笑会太搞笑了
by 呆呆的她啊 @ 2023-11-02 18:09:04
// luogu-judger-enable-o2
#include<cstdio>
#include<iostream>
using namespace std;
int z=1,s[100005],y[100005],sum,n;
void x(int c)
{
for(int i=1;i<=z;++i)
s[i]*=c; int i=1;
while(s[i]>9||i<z)
{
s[i+1]+=s[i]/10;
s[i]%=10;
i++;
}
z=i;
}
void a()
{
for(int i=1;i<=z;++i)
{
y[i]+=s[i];
if(y[i]>9)
{
y[i+1]+=y[i]/10;
y[i]%=10;
sum=max(sum,i+1);
}
sum=max(sum,i);
}
}
int main()
{
scanf("%d",&n);
s[z]=1;
for(int i=1;i<=n;++i)
{
x(i),a();
}
for(int i=sum;i>=1;--i)
{
printf("%d",y[i]);}
}
by chillLee @ 2023-11-02 18:10:25
慢了一步!!!
不过我也想表示一下有点搞笑