15093432132cqt @ 2023-09-24 11:45:30
#include <bits/stdc++.h>
using namespace std;
int sum[11],x,sum1=1,a[1000000],k,s;
void cheng(){
for(int i=2;i<=x;i++){
a[i]*=i;
a[i+1]+=a[i]/10;
a[i]%=10;
k++;
}
for(int i=1;i<=k;i++){
if(a[i]==s) sum[x]++;
}
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>x>>s;
cheng();
}
for(int i=1;i<=10;i++){
if(!sum[i]) cout<<sum[i];
}
}
记得简略一下啊
by joe_001 @ 2023-10-27 22:03:31
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],len,s,t,z;
int main()
{
cin>>s;
for(int k=1;k<=s;k++)
{
cin>>n;
cin>>t;
memset(a,0,sizeof(a));
a[1]=1;
len=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=len;j++)
a[j]*=i;
for(int j=1;j<=len;j++)
{
a[j+1]+=a[j]/10;
a[j]%=10;
}
if(a[len+1]>0)
len++;
while(a[len]>=10)
{
a[len+1]+=a[len]/10;
a[len]%=10;
len++;
}
}
z=0;
for(int j=1;j<=len;j++)
if(a[j]==t)
z++;
cout<<z<<endl;
}
return 0;
}