自己觉得没错,样例也过了但是0分,求指导!!!

P1591 阶乘数码

mab123456 @ 2024-07-15 18:48:35

#include<bits/stdc++.h>
using namespace std;
int t,ans;
int a[100],b[100];
int yj(int a,int e)
{
    int b=1;
    for(int i=1;i<=a;i++)
    {
        b*=i;    
    }
    while(b!=0)
    {
        int c=b%10;
        if(c==e)
        ans++;
        b/=10;
    }
    return ans;
}
int main()
{
    cin>>t;
    for(int i=0;i<t;i++)
    {
    cin>>a[i]>>b[i];
    if(b[i]==0)
    cout<<yj(a[i],b[i])-1<<endl;
    else
    cout<<yj(a[i],b[i])<<endl;; 
    }
    return 0;
}

by PhirainEX @ 2024-07-15 18:55:51


|