求助!
查看原帖
求助!
636849
HiCode2009楼主2022/8/19 10:39

rt,样例能过

#include<bits/stdc++.h>
using namespace std;
int p[2570],n,a,x,t,cnt,len=1;//1000!有2568位
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)//for和while都不行
	{
		cin>>n>>a;
		p[1]=1;
		for(int j=1;j<=n;++j)
		{
			x=0;
			for(int k=1;k<=len;++k)
			{
				p[k]=p[k]*j+x;
				x=p[k]/10;
				p[k]=p[k]%10;
				if(x>0&&k>=len) len++;
			}
		}//阶乘
		for(int j=len;j>=1;j--)
			if(p[j]==a)
				cnt++;//看a出现了多少次
		cout<<cnt<<endl;
		cnt=0;
	}
	return 0;
   //自己试过了,不是n=0的时候出锅
} 
2022/8/19 10:39
加载中...