FBI_Hu_Tao @ 2023-08-11 08:40:32
#include<bits/stdc++.h>
using namespace std;
int n;
char a1[1001],a2[1001];
int a[1001],b[1001],c[1001],d[1001],ans[1001];
int lena=1,lenc,lend,lenans;
void times(int x){
lenc=0;
int lenb=0;
while(x>0){
b[++lenb]=x%10;
x/=10;
}
int xx=0;
memset(c,0,sizeof(c));
for(int i=1;i<=lena;i++){
for(int j=1;j<=lenb;j++){
c[i+j-1]=c[i+j-1]+x+a[i]*b[j];
xx=c[i+j-1]/10;
c[i+j-1]%=10;
}
c[i+lenb]=xx;
}
lenc=lena+lenb;
while(c[lenc]==0&&lenc>1)lenc--;
for(int i=1;i<=lenc;i++)a[i]=c[i];
lena=lenc;
}
void add(){
lend=0;
memset(d,0,sizeof(d));
int x=0;
while(lend<=lena||lend<=lenans){
d[++lend]=a[lend]+ans[lend]+x;
x=d[lend]/10;
d[lend]%=10;
}
while(d[lend]==0&&lend>1)lend--;
for(int i=1;i<=lend;i++)ans[i]=d[i];
lenans=lend;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
memset(a,0,sizeof(a));
a[1]=1;
for(int j=1;j<=i;j++){
times(j);
}
add();
}
for(int i=lenans;i>=1;i--)cout<<ans[i];
cout<<endl;
return 0;
}
by MsgNotFound @ 2023-08-11 08:47:15
为啥我这能过样例@FBI_Hu_Tao
by Weizhuo_Zhao @ 2023-08-11 08:58:10
@FBI_Hu_Tao 打表很香!
#include <iostream>
using namespace std;
int main(){
string a[]={"1","3","9","33","153","873","5913","46233","409113","4037913","43954713","522956313","6749977113","93928268313","1401602636313","22324392524313","378011820620313","6780385526348313","128425485935180313","2561327494111820313","53652269665821260313","1177652997443428940313","27029669736328405580313","647478071469567844940313","16158688114800553828940313","419450149241406189412940313","11308319599659758350180940313","316196664211373618851684940313","9157958657951075573395300940313","274410818470142134209703780940313","8497249472648064951935266660940313","271628086406341595119153278820940313","8954945705218228090637347680100940313","304187744744822368938255957323620940313","10637335711130967298604907294846820940313","382630662501032184766604355445682020940313","14146383753727377231082583937026584420940313","537169001220328488991089808037100875620940313","20935051082417771847631371547939998232420940313","836850334330315506193242641144055892504420940313","34289376947494122614363304694584807557656420940313","1439295494700374021157505910939096377494040420940313","61854558558074209658512637979453093884758552420940313","2720126133346522977702138448994068984204397080420940313","122342346998826717539665299944651784048588130840420940313","5624964506810915667389970728744906677010239883800420940313","264248206017979096310354325882356886646207872272920420940313","12678163798554051767172643373255731925167694226950680420940313","620960027832821612639424806694551108812720525606160920420940313","31035053229546199656252032972759319953190362094566672920420940313"};
int t;
cin >> t;
cout<<a[t-1]<<endl;
return 0;
}
by xiaoshuaibi @ 2023-08-11 09:55:22
#include<bits/stdc++.h>
using namespace std;
int n,ans=1,a[110],b[110]={0,1};
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=100;j++)b[j]*=i;
for(int j=1;j<=100;j++)
if(b[j]>9){
b[j+1]+=b[j]/10;
b[j]%=10;
}
for(int j=1;j<=100;j++){
a[j]+=b[j];
if(a[j]>9){
a[j+1]+=a[j]/10;
a[j]%=10;
}
}
}bool flag=0;
for(int i=100;i>=1;i--){
if(a[i]&&!flag)flag=1;
if(flag)cout<<a[i];
}
return 0;
}
这样很nice
by FBI_Hu_Tao @ 2023-08-12 09:01:17
@42_TZY 你可以去洛谷在线IDE上试试。
by FBI_Hu_Tao @ 2023-08-12 09:04:11
@Weizhuo_Zhao 我只想知道我自己的代码怎么改qwq
by Weizhuo_Zhao @ 2023-08-13 07:54:37
@FBI_Hu_Tao QWQ