_Persever_ance @ 2024-02-25 20:51:20
#include<stdio.h>
#include<string.h>
int main()
{
int a[2100] = { 0 }, b[2100] = { 0 }, c[4200] = { 0 };
int len1 = 0, len2 = 0, i = 0, j = 0, len = 0;
char a1[2100], b1[2100];
gets(a1);
gets(b1);
len1 = strlen(a1);
len2 = strlen(b1);
for (i = 1; i <= len1; i++)
a[i] = a1[len1 - i] - '0';
for (i = 1; i <= len2; i++)
b[i] = b1[len2 - i] - '0';
for (i = 1; i <=len1; i++)
for (j = 1; j <=len2; j++)
c[i+j-1] += a[i] * b[j];
for (i = 1; i < len1 + len2; i++)
{
if (c[i] > 9)
{
c[i + 1] += c[i] / 10;
c[i] %= 10;
}
}
len = len1 + len2;
while (c[len] == 0 && len > 1)
len--;
for (i = len; i >= 1; i--)
printf("%d", c[i]);
return 0;
}
by _Persever_ance @ 2024-02-25 20:52:08
这题识别不了c语言输入方式吗
by _buzhidao_ @ 2024-02-25 20:59:37
@Codelover 多测几组样例
by nlhzh1818 @ 2024-02-25 21:10:46
python(就这么简单):
import sys
sys.set_int_max_str_digits(10000)
num=int(input())
num2=int(input())
print(num*num2)
by zjh114514 @ 2024-02-25 21:15:18
@Codelover 为什么你这代码会输出 -
by zjh114514 @ 2024-02-25 21:22:45
@Codelover int
换成 long
试下?
by Super_Cube @ 2024-02-25 21:35:21
@Codelover 虽然不知道为什么,但是把 gets
换成 scanf
就过了。
before:
gets(a1);
gets(b1);
after:
scanf("%s%s",a1,b1);
by Super_Cube @ 2024-02-25 21:37:57
@Codelover 哦我好像知道了,可能是数据造的不规范,比如说行末有多余空格啥的。
by _Persever_ance @ 2024-02-25 22:14:02
@Super_Cube 确实如此,谢谢佬不然要憋死了
by w_moon @ 2024-04-16 21:07:30
@_Persever_ance gets好像不能用