telankesi @ 2023-01-16 11:55:26
#include<stdio.h>
long long fun(int a, int b) {
int f[10000] = { 0 };
f[1] = 1;
int len = 1;
int t = 1;
while (t <= a)
{
for (int i = 1; i <= len; i++) {
f[i] *= t;
if (f[i] >= 10) {
f[i + 1] += f[i] / 10;
f[i] %= 10;
if (i == len) {
len++;
break;
}
}
}t++;
}
long long num = 0;
for (int i = 1; i <= len; i++) {
if (f[i] == b)num++;
}
return num;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int a, b;
scanf("%d %d", &a, &b);
printf("%lld\n", fun(a, b));
}
return 0;
}
by _xm_ @ 2023-01-19 20:35:11
你长度算的有问题,乘法部分也有问题