70分求助

P1591 阶乘数码

worldcat @ 2024-06-01 14:00:09

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll t,n,a,s[2700],d[2700],len,k;
int main() {
    cin>>t;
    for(int ui=1; ui<=t; ui++) {
        for(int i=1;i<=2600;i++)
        {
            s[i]=0;
        }
        s[1]=1;
        cin>>n>>a;
        for(int r=2; r<=n; r++) {
            for(int i=1; i<=2600; i++) {
                s[i]*=r;
            }
            for(int i=1;i<=2600;i++)
            {
                s[i+1]+=s[i]/10;
                s[i]%=10;
            }
        }
        k=0;
        for(int u=1; u<=2600; u++) {
            if (s[u]==a) {
                k++;
            }
        }
        cout<<k<<endl;
    }
    return 0;
}

前三个点错了


by dmh0612 @ 2024-07-08 20:13:14

@worldcat 数组不够大


by worldcat @ 2024-07-09 07:43:45

@dmh0612 谢谢,已经过了


by dmh0612 @ 2024-07-09 13:03:56

p2005不会,可以教我吗?


by dmh0612 @ 2024-07-09 13:04:45

可以设置一下聊天


|