过样例 但0分 求调
查看原帖
过样例 但0分 求调
845436
gjleeee楼主2023/7/29 23:21
#include <bits/stdc++.h>
using namespace std;

const int MAX=1e5+5;
int t,num[MAX],n,a,len=1,cnt;

void empty(){
	for (int i=0;i<len;i++) num[i] = 0;
	num[0]=1;
	len=1;
	cnt=0;
}

int main(){
	cin>>t;
	
	for (int i=0;i<t;i++){
		empty();
		cin>>n>>a;
		for (int j=2;j<=n;j++){
			for (int k=0;k<len;k++) num[k] *= j;
			int k=0;
			while (true){
				num[k+1] += num[k]/10;
				num[k] %= 10;
				if (num[++k] == 0) break;
			}
			len = k;
		}
		
		for (int j=0;j<len;j++) if (num[j] == a) cnt++;
		cout<<cnt<<endl;
	}
	
	return 0;
}
2023/7/29 23:21
加载中...