今天用memset赋值数组元素,因为我太蒻了,函数的元素顺序写反了。
but 这份代码竟然神奇的AC了!
百思不得其解。(mian函数第一行
#include<bits/stdc++.h>
using namespace std;
int b[1005][2500],n,t,a;
int main(){
memset(b,sizeof(b),0);
b[0][0]=b[1][0]=1;
for(int i=1;i<=1001;i++){
for(int j=0;j<2500;j++){
b[i][j]*=i;
}
for(int j=0;j<2500;j++){
if(b[i][j]>9){
b[i][j+1]=b[i][j+1]+b[i][j]/10;
b[i][j]=b[i][j]%10;
}
b[i+1][j]=b[i][j];
}
}
cin>>t;
while(t--){
cin>>n>>a;
long long ans=0;
int ii=2500;while(ii>=0 and b[n][ii]==0)ii--;
for(int j=ii;j>=0;j--)if(b[n][j]==a)ans++;
cout<<ans<<'\n';
}
return 0;
}