xibaby @ 2024-07-11 18:10:29
#include<bits/stdc++.h>
using namespace std;
int t,n,a,b[2570],s;
int main(){
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&a);
memset(b,0,sizeof(b));
b[1]=1,s=0;
for(int i=1;i<=n;i++){
for(int j=1;j<2569;j++)
b[j]*=i;
for(int j=1;j<2569;j++)
b[j+1] += b[j]/10,b[j]%=10;
}
for(int i=1;i<2569;i++)
if(b[i]==a) s++;
printf("%d\n",s);
}
return 0;
}
by ZYLZPP @ 2024-07-11 18:34:50
@xibaby