Problem A: A+B problem
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 313 Solved: 213
[ Submit][ Status][ Web Board]
Description
Calculate a+b
Input
There are several lines.
The first line contains the number of test cases. In the following, each line contains two integer values seperated by a space.
Output
Output the sum of these values.
Sample Input
3
12345678901 19876543217
54749110547 5474119110
15530259260 130625199010
Sample Output
32222222118
60223229657
146155458270
HINT
These numbers are beyond int types. it will be wrong if you input them directly, so you can use arrays to solve this problem.
#include <stdio.h>
#include <stdlib.h>
int main()
{ int n,i;
long long int s;
scanf("%d",&n);
long long int x[2*n];
for(i=0;i<n;i++){
scanf("\n%lld %lld",&x[2*i],&x[2*i+1]);}
for(i=0;i<n;i++){
s=x[2*i]+x[2*i+1];
printf("%lld\n",s);}
return 0;
}
本文介绍了一个简单的A+B问题,并提供了使用C语言实现的代码示例。该问题要求计算两个大整数的和,由于数值超出了常规整型变量的范围,因此采用数组来存储这些大整数并进行加法运算。
524

被折叠的 条评论
为什么被折叠?



