Help!!!!球球大佬们了!!

P1591 阶乘数码

三十坪 @ 2021-02-03 21:45:40

在vs2019上运行都是对的,但提交没有一个是对的,求大佬帮忙看看,救救可怜的孩子吧!!```c

include<iostream>

using namespace std; int a[3000]; void cheng(int a, int c) { int jw = 0; for (int i = 0; i < 3000; i++) { a[i] = a[i] c + jw; jw = a[i] / 10; a[i] = a[i] % 10; } } int main() { int t; cin >> t; int d[10]; int d1 = 0; for (int i = 0; i < t; i++) { int n, b; cin >> n >>b; a[1] = 1; for (int j = 1; j <= n; j++) { cheng(a, j); } int num = 0; int k; for (int j = 3000; j > 0; j--) { if (a[j] != 0) { k = j; break; } } for (int j = 1; j <= k; j++) { if (a[j] == b) { num++; } } d[d1] = num; d1++; } for (int i = 0; i < d1; i++) { cout << d[i] << endl; } return 0; }


by osfly @ 2021-02-03 21:46:51

@我有小也 建议重新复制代码


by tribool4_in @ 2021-02-03 21:53:50

希望更丰富的展现?使用Markdown


by _caiji_ @ 2021-02-03 21:55:11

#include<iostream>
using namespace std;
int a[3000];
void cheng(int* a, int c) {
    int jw = 0;
    for (int i = 0; i < 3000; i++) {
        a[i] = a[i] * c + jw;
        jw = a[i] / 10;
        a[i] = a[i] % 10;
    }
}
int main() {
    int t; cin >> t;
    int d[10];
    int d1 = 0;
    for (int i = 0; i < t; i++) {
        int n, b;
        cin >> n >>b;
        a[1] = 1;
        for (int j = 1; j <= n; j++) {
            cheng(a, j);
        }
        int num = 0;
        int k;
        for (int j = 3000; j > 0; j--) {
            if (a[j] != 0) {
                k = j;
                break;
            }
        }
        for (int j = 1; j <= k; j++) {
            if (a[j] == b) {
                num++;
            }
        }
        d[d1] = num;
        d1++;
    }
    for (int i = 0; i < d1; i++) {
        cout << d[i] << endl;
    }
    return 0;
}

|