fanqianyi @ 2021-01-25 21:52:07
#include<stdio.h>
int a[1001]={0,1},m,n;
void count(int ,int );
int main()
{
int i,t,j;
scanf("%d",&t);
for(i=1;i<=t;i++){
scanf("%d %d",&m,&n);
count(m,n);
}
return 0;
}
void count(int m,int n)
{
int count,i,j;
for(j=2;j<=m;j++){
for(i=1;i<=1000;i++) a[i]*=j;
for(i=1;i<=1000;i++){
if(a[i]>9){
a[i+1]+=a[i]/10;
a[i]%=10;
}
}
}
for(i=1000;a[i]==0&&i!=0;i--);
for(count=0;i>0;i--){
if(a[i]==n) count++;
a[i]=0;
}
a[1]=1;
printf("%d\n",count);
}