YLLRML @ 2025-01-02 19:04:45
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
vector<int> v1, v2;
char c;
while (scanf("%c", &c))
{
if (c == '\n') break;
v1.push_back(c - '0');
}
while (scanf("%c", &c))
{
if (c == '\n') break;
v2.push_back(c - '0');
}
int i = v1.size(), j = v2.size();
if (i < j)
{
swap(v1, v2);
swap(i, j);
}
vector<int> v3(i, 0);
int k,l,a,b,count;
for (j--,count=0; j >= 0;count++,j--)
{
for (k = i-1,a=0,b=0,l = v3.size()-1-count; l>=0; k--,l--)
{
a = v1[k] * v2[j] + a;
b = v3[l] + a % 10+b;
v3[l] = b % 10;
a /= 10;
b /= 10;
}
while(k>=0)
{
v3.insert(v3.begin(), 0);
a = v1[k] * v2[j] + a;
b = v3[0] + a % 10+b;
v3[0] = b % 10;
a /= 10;
b /= 10;
k--;
}
while (a != 0 || b != 0)
{
v3.insert(v3.begin(), 0);
b = v3[0] + a % 10 + b;
v3[0] = b % 10;
a /= 10;
b /= 10;
}
}
if (v3[0] == 0)
{
cout << v3[0];
return 0;
}
for (auto it : v3)
cout << it;
return 0;
}
by LionBlaze @ 2025-01-02 19:15:10
@YLLRML 不是,
by YLLRML @ 2025-01-02 19:30:02
@LionBlaze 我知道,但是我的循环里后面会自动头插
by gaohongyuan @ 2025-01-02 19:31:10
@LionBlaze 他写的好复杂
by YLLRML @ 2025-01-02 19:31:36
@LionBlaze 如果可以的话,你试试复制我的代码运行一下看看结果就知道了
by LionBlaze @ 2025-01-02 19:33:50
写 abc386 翻译 ing
by YLLRML @ 2025-01-02 19:45:28
@LionBlaze 直接运行测试算出来的数没问题啊
by YLLRML @ 2025-01-02 19:48:22
@LionBlaze ?