jimmyshi29 @ 2020-08-13 13:30:36
# include <iostream>
# include <string>
# include <cstdio>
using namespace std;
void mulBIG(int x[], int y, int z[])
{
z[0] = x[0];
for (int i = 1; i <= z[0]; i++)
{
z[i] = x[i] * y;
}
for (int i = 1; i <= z[0]; i++)
{
z[i + 1] += z[i] / 10;
z[i] %= 10;
}
while (z[z[0] + 1] > 0)
{
z[0]++;
z[z[0] + 1] += z[z[0]] / 10;
z[z[0]] %= 10;
}
}
// 把字符串s存储的整数按照大整数的格式存入数组x中
void s2BIG(string s, int x[])
{
int lx = s.length();
for (int i = 1; i <= lx; i++)
{
// 数组x和十进制写法是反过来存储的
x[i] = s[lx - i] - '0';
}
x[0] = lx; // 大整数的位数保存在x[0]
}
// 用一行输出x代表的大整数(包括换行符)
void printBIG(int x[])
{
int lx = x[0];
for (int i = lx; i >= 1; i--)
{
printf("%d", x[i]);
}
printf("\n"); // 最后要输出一个换行
}
int a[1010];
int b;
int c[1010];
int main()
{
string s;
cin >> s >> b;
s2BIG(s, a);
mulBIG(a, b, c);
printBIG(c);
return 0;
}
40qwq
by Andy_chen @ 2020-08-13 13:31:47
cin >> s >> b;
by Andy_chen @ 2020-08-13 13:32:49
每个数字不超过
10^{2000} ,需用高精。
by Uniseca @ 2020-08-13 13:34:26
a,b = map(int,input().split(' '))
print(a*b)
(逃
by 幻影星坚强 @ 2020-08-13 13:35:14
两个数都要用高精度,而且数组不够大
by jimmyshi29 @ 2020-08-13 13:36:04
@Andy_chen 我*是高精乘高精???
by jimmyshi29 @ 2020-08-13 13:36:38
@255_NyanCat ?
by Andy_chen @ 2020-08-13 13:36:43
@jimmyshi29 请看清楚题目。
by jimmyshi29 @ 2020-08-13 13:37:48
@Andy_chen 但我没学呀
by Andy_chen @ 2020-08-13 13:38:35
@jimmyshi29 我也没学,所以别做就得了
by Andy_chen @ 2020-08-13 13:39:11
@jimmyshi29 建议学习FFT,特别简单