全WA求助!

P1591 阶乘数码

interory @ 2024-11-10 12:11:33

#include <iostream>
using namespace std;
#define int long long
int arr[15];
signed main(){
    int a,b=1,c,d=1,e;
    cin>>a;
    memset(arr,0,sizeof(arr));
    for(int i=1;i<=a;i++){
        int temp=1,num=0;
        cin>>b>>e;
        for(int j=1;j<=b;j++){
            temp=temp*j; 
        }
        while(temp>0){
            c=temp%10;
            if(c==e){
                num++;
            }
            temp=temp/10;
        }
        arr[i]=num;
    }
    for(int i=1;i<=a;i++){
        cout<<arr[i]<<endl;
    }
    return 0;
}

by interory @ 2024-11-10 12:11:56

qb(bushi


by interory @ 2024-11-10 12:12:21

qp


by zxw1234567 @ 2024-11-10 12:17:54

希望能帮助你


#include <bits/stdc++.h>
using namespace std;
int c[100000];
int main()
{
  int t,n,a;
  cin>>t;
  for(int i=0; i<t; i++){
    cin>>n>>a;
    memset(c,0,sizeof(c));
    c[0]=1;
    int l=1;
    for(int j=2; j<=n; j++){
      int w=0;
      for(int k=0; k<l; k++){
        c[k]=c[k]*j+w;
        w=c[k]/10;
        c[k]%=10;
      }
      while(w>0){
        c[l]=w%10;
        l++;
        w/=10;
      }
    }
    int sum=0;
    for(int j=0; j<l; j++)
      if(c[j]==a) sum++;
    cout<<sum<<endl;
  }
  return 0;
}

by zxw1234567 @ 2024-11-10 12:19:03

@interory 能给关注吗


by interory @ 2024-11-11 18:53:17

@zxw1234567

include <bits/stdc++.h>
using namespace std;
int main(){
  cout<<"包可以的";
  return 0;
}

|