littlewhite_ @ 2023-09-24 10:33:07
1号测试点WA,5号RE
#include <bits/stdc++.h>
using namespace std;
int la, lb, lans, a[1010], b[1010], c[1010], ans[1010];
void Read(int *a, int &len)
{
string cur;
cin >> cur;
len = cur.length();
for (int i = 0; i < len; i++)
{
a[len - i - 1] = cur[i] - '0';
}
return;
}
int main()
{
Read(a, la);
Read(b, lb);
lans = la + lb - 1;
for (int i = 0; i < la; i++)
{
for (int j = 0; j < lb; j++)
{
ans[i + j] += a[i] * b[j];
}
}
for (int i = 0; i <= lans; i++)
{
if (ans[i] > 9)
{
ans[i + 1] = ans[i + 1] + ans[i] / 10;
ans[i] = ans[i] % 10;
}
}
if (ans[lans])
{
lans++;
}
for (int i = lans - 1; i >= 0; i--)
{
cout << ans[i];
}
return 0;
}
by luogu_sdfx1803 @ 2023-09-24 11:09:40
一方面是数组开小了,把这几个数组都开到10100,就可以得80分了。
by Foggy_night @ 2023-09-24 17:31:32
我觉得你的长度求错了