最简单的题目

来源:百度知道 编辑:UC知道 时间:2024/06/18 03:20:32
Problem Description
Calculate A * B.

Input
Each line will contain two integers A and B. Process to end of file.

Note: the length of each integer will not exceed 50000.

Output
For each case, output A * B in one line.

Sample Input
1
2
1000
2

Sample Output
2
2000

我:
#include<stdio.h>
void main()
{
unsigned long a,b,c;
while(scanf("%lu%lu",&a,&b)!=EOF)
{
printf("%lu\n",c=a*b);
}
}

Note: the length of each integer will not exceed 50000.

50000位已经远远超过long 型数字的范围,需要高精度乘法来做的。

高精度就是用数组来存放结果,通常每个数组元素存4位

printf("%lu\n",a*b);