Exile_Code @ 2023-07-16 16:51:54
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <list>
#include <string>
#include <cmath>
#include <bitset>
vector<long long >mul(vector<long long >A, vector<long long >B) {
vector<long long >C(A.size() + B.size());
for (int i = 0; i < A.size(); i++) {
for (int j = 0; j < B.size(); j++) {
C[i + j] += A[i] * B[j];
C[i + j + 1] += C[i + j] / 10;
C[i + j] %= 10;
}
}
while (C.size() > 0 && C.back() == 0)C.pop_back();
return C;
}
int main() {
int t; cin >> t;
while (t--) {
int a, b; cin >> a >> b;
vector<long long >B(1);
vector<long long >A(1);
A[0] = 1; long long sum = 0;
for (int i = 1; i <= a; i++) {
B[0] = i;
A = mul(A, B);
}
for (auto a : A) {
if (a == b) {
sum++;
}
}
cout << sum << endl;
}
return 0;
}
by heyx0201 @ 2023-07-16 17:05:14
@Exile_Code 你说你有必要写这么多头文件吗……
by heyx0201 @ 2023-07-16 17:05:48
@Exile_Code 建议加点注释,蒟蒻看不懂啊……
by zhuxiangrui_2010 @ 2023-07-16 17:10:48
@Codehyx +1 @Exile_Code 用高精度
by Exile_Code @ 2023-07-16 18:05:23
@zhuxiangrrr 是高精度的