0分求助!!!第一个回复有惊喜(私信)

P1591 阶乘数码

dongrq_cs @ 2023-04-01 20:13:28

#include <bits/stdc++.h>
using namespace std;
int n;
int a[1001],b[1001];
int f(int a){
    int sum = 1;
    for(int i = 1;i <= a;i++){
        sum *= i;
    }
    return sum;
}
int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0;i < n;i++){
        int cnt = 0;
        int m = f(a[i]);
        while(m){
            if(m % 10 == b[i]){
                cnt++;
            }
            m /= 10;
        }
        cout << cnt << endl;
    }
    return 0;
}

by Bauman @ 2023-04-17 15:40:33

好像可以,那个没考上.....


by dingding2008 @ 2023-05-13 21:04:24

呃,long long貌似存不下吧?要用高精度乘低精度才能写,不会可以看一下网上的教程(很简单,我AC了)


by aidsao @ 2024-07-15 10:10:30

@dongrq_cs 到底过没过,过了惊喜呢?


上一页 |