WA 5#, 求debug

P1303 A*B Problem

esquigybcu @ 2020-11-21 15:13:39

Code:

#include <stdio.h>
#include <string.h>
const int SIZE = 2005;
char a[SIZE], b[SIZE];
unsigned long long c[2*SIZE];

int main()
{
    int sizea, sizeb, started = 0;
    scanf("%s %s", a, b);
    sizea = strlen(a);
    sizeb = strlen(b);
    for (int i = 0; i < sizea; i++)
    {
        a[SIZE-sizea+i] = a[i] - '0';
        a[i] = 0;
    }
    for (int i = 0; i < sizeb; i++)
    {
        b[SIZE-sizeb+i] = b[i] - '0';
        b[i] = 0;
    }
    for (int i = 0; i < sizea; i++)
        for (int j = 0; j < sizeb; j++)
        {
            c[2*SIZE-i-j-1] += a[SIZE-i-1] * b[SIZE-j-1];
            c[2*SIZE-i-j-2] += c[2*SIZE-i-j-1] / 10;
            c[2*SIZE-i-j-1] %= 10;
        }
    for (int i = 0; i < 2*SIZE; i++)
    {
        started |= c[i] != 0;
        if (started)
            putchar(c[i] + '0');
    }
    if (!started) putchar('0');
    return 0;
}

|