YJC_____ @ 2024-12-07 17:59:13
#include<bits/stdc++.h>
using namespace std;
int main() {
int t, n, a;
int ans[10010] = {0};
cin >> t;
for (int x = 1; x <= t; x++) {
cin >> n >> a;
ans[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 2500; j++)
ans[j] *= i;
for (int j = 0; j < 2500; j++)
if (ans[j] > 9) {
ans[j + 1] += ans[j] / 10;
ans[j] %= 10;
}
}
int cnt = 2500, cnt2 = 0;
while (ans[cnt] == 0){
cnt--;
}
for (int i = 0; i <= cnt; i++) {
if (ans[i] == a){
cnt2++;
}
ans[i] = 0;
}
cout << cnt2 <<endl;
}
return 0;
}
0
90
by dendky @ 2024-12-17 19:19:10
@222yjc
#include<bits/stdc++.h>
using namespace std;
int ans[10010];//这里我开了全局
int main() {
int t, n, a;
cin >> t;
for (int x = 1; x <= t; x++) {
cin >> n >> a;
ans[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 2600; j++)
ans[j] *= i;
for (int j = 0; j < 2600; j++)
if (ans[j] > 9) {
ans[j + 1] += (ans[j] / 10);
ans[j] %= 10;
}
}
int cnt = 2600, cnt2 = 0;
while (ans[cnt] == 0){
cnt--;
}
for (int i = 0; i <= cnt; i++) {
if (ans[i] == a){
cnt2++;
}
ans[i] = 0;
}
cout << cnt2 <<endl;
}
return 0;
}
把2500改成2600就过了QAQ
by dendky @ 2024-12-17 19:19:30
@222yjc这个码风我羡慕
by YJC_____ @ 2024-12-18 19:11:11
@dendky栓Q栓Q关注了