题目

Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C.

Input Specification:

The first line of the input gives the positive number of test cases, T (<=10).  Then T test cases follow, each consists of a single line containing three integers A, B and C, separated by single spaces.

Output Specification:

For each test case, output in one line "Case #X: true" if A+B>C, or "Case #X: false" otherwise, where X is the case number (starting from 1).

Sample Input:

3
1 2 3
2 3 4
9223372036854775807 -9223372036854775808 0

Sample Output:

Case #1: false
Case #2: true
Case #3: false

须要考A+B虑溢出的问题。可能是上界。也可能是下界。

能够考虑string模拟大数的方法,代码用了一种适用于两个元素的投机方法。

代码:

#include <iostream>
using namespace std; int main()
{
int n;
cin>>n; long long a,b,c;
int i,j;
for(i=0;i<n;i++) //一种投机取巧的办法。仅适用于两个元素
{
cin>>a>>b>>c;
cout<<"Case #"<<i+1<<": ";
if(a>0&&b>0&&a+b<a&&a+b<b) //上越界,必定大于c
cout<<"true\n";
else if(a<0&&b<0&&a+b>a&&a+b>b) //下越界,必定小于c
cout<<"false\n";
else if(a+b>c) //常规比較
cout<<"true\n";
else
cout<<"false\n";
} return 0;
}

最新文章

  1. 【学习笔记】Struts2 应用开发步骤
  2. django static文件的引入方式
  3. flash链接需要后台调用时的插入flash方法
  4. C#调用C++编写的DLL函数, 以及各种类型的参数传递 z
  5. bzoj1415
  6. SendMessage和PostMessage区别以及WPARAM 和 LPARAM区别
  7. MVC5 Entity Framework学习之Entity Framework高级功能
  8. Angular开发技巧
  9. Go之十大经典排序算法
  10. 简单易懂的softmax交叉熵损失函数求导
  11. 基于xlua和mvvm的unity框架
  12. 任意目录下启动tomcat
  13. [转]Mariadb的root密码忘记后的解决方法
  14. 1. dubbo概述
  15. windows安装weblogic并集成到eclipse
  16. Linux command stty
  17. spring+mybatis+mina+logback框架搭建
  18. Linux常用基本命令wc-统计文件的字节,字符,行数
  19. js+ajax+springmvc实现无刷新文件上传
  20. ZC_C++类函数指针_模拟_Delphi类函数指针_Qt例子

热门文章

  1. GridBagLayout练习
  2. android-读取Assets图片资源保存到SD - 随心
  3. 《你必须知道的495个C语言问题》知识笔记及补充
  4. ZOJ Monthly, June 2014 月赛BCDEFGH题题解
  5. Vlc基础数据结构记录
  6. pl/sql连接远程服务器
  7. V - 不容易系列之(4)――考新郎(第二季水)
  8. linux学习笔记之sudo
  9. bootstrap输入框从数据库读取数据
  10. AspectJ的安装和Eclipse的AJDT插件的配置