You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
782 B
35 lines
782 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
//高精度乘法模板
|
|
vector<int> mul(vector<int> &A, int b) {
|
|
vector<int> C;
|
|
int t = 0;
|
|
for (int i = 0; i < A.size() || t; i++) {
|
|
if (i < A.size()) t += A[i] * b;
|
|
C.push_back(t % 10);
|
|
t /= 10;
|
|
}
|
|
while (C.size() > 1 && C.back() == 0) C.pop_back();
|
|
return C;
|
|
}
|
|
|
|
int main() {
|
|
int t;
|
|
cin >> t;
|
|
for (int i = 1; i <= t; i++) {
|
|
int n, a;
|
|
cin >> n >> a;
|
|
|
|
vector<int> A;
|
|
int cnt = 0;
|
|
//倒着放的噢~
|
|
A.push_back(1);
|
|
for (int j = 2; j <= n; j++) A = mul(A, j);
|
|
for (int j = 0; j < A.size(); j++)
|
|
if (A[j] == a) cnt++;
|
|
cout << cnt << endl;
|
|
}
|
|
return 0;
|
|
} |