gjleeee @ 2023-07-29 23:21:26
#include <bits/stdc++.h>
using namespace std;
const int MAX=1e5+5;
int t,num[MAX],n,a,len=1,cnt;
void empty(){
for (int i=0;i<len;i++) num[i] = 0;
num[0]=1;
len=1;
cnt=0;
}
int main(){
cin>>t;
for (int i=0;i<t;i++){
empty();
cin>>n>>a;
for (int j=2;j<=n;j++){
for (int k=0;k<len;k++) num[k] *= j;
int k=0;
while (true){
num[k+1] += num[k]/10;
num[k] %= 10;
if (num[++k] == 0) break;
}
len = k;
}
for (int j=0;j<len;j++) if (num[j] == a) cnt++;
cout<<cnt<<endl;
}
return 0;
}
by Zaifuzaifu @ 2023-08-08 10:20:46
while循环里写错了,如果一个数的阶乘中间有0,你就不会进位了
by Zaifuzaifu @ 2023-08-08 10:21:43
前导0也没去除,数组肯定往大开,你读取一遍,数组前面肯定会有一片0
by Zaifuzaifu @ 2023-08-08 10:22:33
@Zaifuzaifu 你可以试试输一个n(比较大),a是0试试
by gjleeee @ 2023-08-12 14:58:48
@Zaifuzaifu 谢大佬 过了