直接拿下
2025-09-29 18:13:45
发布于:上海
1阅读
0回复
0点赞
#include<iostream>
#include<vector>
using namespace std;
struct node{
int num,a;
};
vector<vector<int>> mp;
int t,m;
void js(int maxn){
mp.resize(maxn + 5);
mp[0] = {1};
mp[1] = {1};
for(int i = 2;i <= maxn;i++){
mp[i] = mp[i - 1];
int c = 0;
for(int j = 0;j < mp[i].size();j++){
int product = mp[i][j] * i + c;
mp[i][j] = product % 10;
c = product / 10;
}
while(c){
mp[i].push_back(c % 10);
c /= 10;
}
}
}
void out(node o){
int x = o.num,a = o.a,ans = 0;
for(auto i : mp[x]) ans += (i == a);
cout << ans << endl;
}
int main(){
vector<node> a;
cin >> t;
while(t--){
int x,y;
cin >> x >> y;
a.push_back({x,y});
m = max(m,x);
}
js(m);
for(auto i : a){
out(i);
}
return 0;
}
这里空空如也
有帮助,赞一个