hoj 1002

For each pair of integers A B and C ( -2^31 <= A, B, C<= 2^31-1 ), Output the result of A+B+C on a single line.

Sample Input

1 2 3
3 4 3

Sample Output

6
10
#include <stdio.h>
#include <stdlib.h>

int main()
{
   long long int a,b,c;
   while(scanf("%I64d %I64d %I64d",&a,&b,&c)==3)
   {
     printf("%I64d
",a+b+c);
   }
   return 0;
}

这道题目一开始以为和1000一样只不过是三个数而已,但是WA后再看题,发现是A、B、C都在-2^31 ~2^31,所以用int或者long都会数据溢出。上网一查, 原来还有long long int这种数据类型(%lld,或者%l64d,不同编译器lld会报错比如我的)。这种数据类型就不会出现数据溢出了。

原文地址:https://www.cnblogs.com/kugwzk/p/5045673.html