自己输入的数测试都没问题 但是只有20分

P1303 A*B Problem

kkkllj @ 2022-12-06 17:21:50

#include <stdio.h>
#include <string.h>

#define Arrsize 2003
#define ansArrsize 4000000

int a[Arrsize];
int b[Arrsize];
int c[ansArrsize] = { 0 };

int main() {
    char temp[Arrsize];
    scanf(" %s", temp);
    int la = strlen(temp);

    for (int i = 0; i < la; i++) {
        a[la - i] = temp[i]-'0';
    }

    scanf(" %s", temp);
    int lb = strlen(temp);

    for (int i = 0; i < lb; i++) {
        b[lb - i] = temp[i]-'0';
    }

    for (int i = 1; i <= la; i++) {
        for (int j = 1; j <= lb; j++) {
            c[i + j - 1] += a[i] * b[j];
            if (c[i + j - 1] >= 10) {
                c[i + j] += c[i + j - 1] / 10;
                c[i + j - 1] %= 10;
            }
        }
    }

    int lc = la > lb ? la : lb;

    while (c[lc+1] > 0) {
        lc++;
    }
    while (c[lc] == 0 && lc>1) {
        lc--;
    }

    for (int i = lc; i >= 1; i--) {
        printf("%d", c[i]);
    }
    return 0;
}

by DYYqwq @ 2022-12-06 17:32:30

Py了解一下


by kkkllj @ 2022-12-06 20:32:32

@DongYUyao 啥叫py


by DYYqwq @ 2022-12-06 20:52:07

@kkkllj python,一种编程语言


|