1_1_1_1_1_1_ @ 2023-11-08 19:22:52
#include<bits/stdc++.h>
#define N 100000
using namespace std;
int a[N];
int t, n, m;
int q()
{
int i, j;
int len = 1, cnt = 0;
memset(a, 0, sizeof(a));
a[1] = 1;
for(i = 2; i <= n; i++)
{
for(j = 1; j <= len; j++)
{
a[j] = a[j] * i;
}
for(j = 1; j <= len + 15; j++)
{
a[j + 1] += a[j] / 10;
a[j] = a[j] % 10;
}
while(a[len + 1] != 0)
{
len++;
}
}
for(i = 1; i <= len; i++)
{
if(a[i] == m)
{
cnt++;
}
}
return cnt;
}
int main()
{
int i;
ios::sync_with_stdio(0);
cin >> t;
for(i = 1; i <= t; i++)
{
cin >> n >> m;
cout << q() << endl;
}
return 0;
}
by Cy_AlphaKai_CCF @ 2023-11-08 20:34:43
@1_1_1_1_11
#include <iostream>
#include <cstring>
using namespace std;
int f[5001];
void mmultip(int a[], int c) {
int jw = 0;
for (int i=1; i<=5000; ++i) {
a[i] = a[i] * c + jw;
jw = a[i] /10;
a[i] %= 10;
}
}
int countA (int n, int a) {
int i, count = 0;
memset(f, 0, sizeof(f));
f[1] = 1;
for (i=2; i<=n; ++i)
mmultip(f, i);
for (i=5000; f[i] == 0; --i);
for (; i>=1; --i)
if (f[i] == a)
++count;
return count;
}
int main() {
int t;
cin >> t;
int n[t], a[t], ans[t];
for (int i=0; i<t; ++i)
cin >> n[i] >> a[i];
for (int i=0; i<t; ++i)
ans[i] = countA(n[i], a[i]);
for (int i=0; i<t; ++i)
cout << ans[i] << endl;
return 0;
}
求关
顺便关注一下我的 百度账号
by 1_1_1_1_1_1_ @ 2023-11-08 21:41:12
@2931Coupler 看不懂