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 jimmyshi29 @ 2020-08-13 13:40:03
@Andy_chen ?
by Andy_chen @ 2020-08-13 13:41:28
@jimmyshi29 https://www.luogu.com.cn/problem/P1919
by jimmyshi29 @ 2020-08-13 13:46:18
@Andy_chen 跟这题有区别吗
by 云岁月书 @ 2020-08-13 13:49:47
FFT 和这题的区别大的很,是要求
然后代码:
int a[1010];
int b;
int c[1010];
这里数组显然开小了。