Hayya @ 2024-10-04 11:45:27
#include<bits/stdc++.h>
using namespace std;
int a[200],b[200];
int main()
{
a[200]={0};
a[0]=1;
b[200]={0};
b[0]=1;
int n,m=1;
cin>>n;
if(n==0||n==1) cout<<"1"<<endl;
else
{
for(int i=2;i<=n;i++)
{
int x=0;
for(int j=0;j<m;j++)
{
int tmp;
tmp=x+a[j]*i;
a[j]=tmp%10;
x=tmp/10;
}
while(x)
{
a[m++]=x%10;
x/=10;
}
int y=0;
for(int i=0;i<=m;i++)
{
int tmp2;
tmp2=a[i]+b[i]+y;
b[i]=tmp2%10;
y=tmp2/10;
}
}
if(b[m]==0){
for(int i=m-1;i>=0;i--) cout<<b[i];}
else {
for(int i=m;i>=0;i--)
cout<<b[i];
}
}
return 0;
}
by dongzirui0817 @ 2024-10-04 11:56:51
@Hayya 话说你样例都没过耶……
by kanqiqin @ 2024-10-04 11:56:57
#include <bits/stdc++.h>
using namespace std;
string a[] = {"0", "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 main() {
int n;
cin >> n, cout << a[n];
}
by kanqiqin @ 2024-10-04 11:59:16
@Hayya
当我放屁
#include<stdio.h>
int main()
{
int i,A[1005]={0},B[1005]={0},n,j;
scanf("%d", &n);
A[0]=B[0]=1;
for (i=2;i<=n;i++){
for (j=0;j<100;j++)
B[j]*=i;
for (j=0;j<100;j++)
if (B[j]>9){
B[j+1] += B[j]/10;
B[j]%=10;
}
for (j=0;j<100;j++){
A[j]+=B[j];
if (A[j]>9) {
A[j+1] += A[j]/10;
A[j]%=10;
}
}
}
for (i=100;i>=0&&A[i]==0;i--);
for (j=i;j>=0;j--) printf("%d", A[j]);
return 0;
}
by Felixy_2012 @ 2024-10-04 12:03:05
把
a[200]={0};
改成
memset(a,0,sizeof(a));
就A了(B同样操作)。
by Felixy_2012 @ 2024-10-04 12:03:51
@Hayya
by Felixy_2012 @ 2024-10-04 12:06:31
关O2也行
by Felixy_2012 @ 2024-10-04 12:07:25
删6,8行还行
by Hayya @ 2024-10-04 12:22:13
@Felixy_2012 过了,谢谢!