Advance626 @ 2023-01-15 22:46:10
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<vector>
#include<cmath>
#include<cctype>
#define IOS std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
#define pi acos(-1);
#include<map>
int t,n,a;
using namespace std;
typedef struct node{
}node;
vector<int>A;
vector<int>mul(vector<int>A,int x){
vector<int>C;
int t=0;
for(int i=A.size()-1;i>=0;i--){
t+=A[i]*x;
C.push_back(t%10);
t/=10;
}
if(t)C.push_back(t);
while(C.size()>1&&C.back()==0)C.pop_back();
reverse(C.begin(),C.end());
return C;
}
void ccin(){
}
void work(){
}
int main(){
IOS;
cin>>t;while(t--){
cin>>n>>a;
A.clear();
A.push_back(1);
for(int i=1;i<=n;i++){
A=mul(A,i);
}
int sum=0;
for(int i=0;i<A.size();i++){
if(A[i]==a)sum++;
}
cout<<sum<<endl;
}
return 0;
}
by Killer_joke @ 2023-01-15 23:10:13
把
if(t)C.push_back(t);
改为
while(t){
C.push_back(t%10);
t/=10;
}
即可
by Advance626 @ 2023-01-16 22:03:24
@Killer_joke 谢谢大佬帮助,已过,已经理解,再次感谢