SOS大佬们,看完题解后复现,但是全WA

P1009 [NOIP1998 普及组] 阶乘之和

WINHHH666 @ 2023-01-10 19:51:59

#include <iostream>
using namespace std;

int a[101] = {0}, s[101] = {0};

void ji(int x) {
    int g = 0;
    for (int i = 100; i >= 0; i--) {
        a[i] = a[i] * x + g;
        a[i] = a[i] % 10;
        g = a[i] / 10;
    }
}

void he() {
    int h = 0;
    for (int i = 100; i >= 0; i--) {
        s[i] = s[i] + a[i] + h;
        h = s[i] / 10;
        s[i] = s[i] % 10;
    }
}

void shu() {
    int w = 0;
    for (int i = 0; i <= 100; i++) {
        if (s[i] != 0) {
            w = i;
            break;
        }
    }
    for (int i = w; i <= 100; i++) {
        cout << s[i];
    }
}

int main() {

    int n;
    cin >> n;
    a[100] = s[100] = 1;
    for (int i = 2; i <= n; i++) {
        ji(i);
        he();
    }
    shu();

    return 0;
}

by WINHHH666 @ 2023-01-10 19:53:26

SOS


by WINHHH666 @ 2023-01-10 20:26:43

找出来了


|