1065. A+B and C (64bit) (20)
2014-02-14 16:18
381 查看
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:
Sample Output:
思路:根据是否溢出来做 ,但是好郁闷 arr[i].a+arr[i].b作为整体时就出错! long long total = arr[i].a+arr[i].b; 用total代替就OK' 真心搞不懂啊!!
AC代码:
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
思路:根据是否溢出来做 ,但是好郁闷 arr[i].a+arr[i].b作为整体时就出错! long long total = arr[i].a+arr[i].b; 用total代替就OK' 真心搞不懂啊!!
AC代码:
#include <iostream> using namespace std; int N; struct Node{ long long a; long long b; long long c; }; Node arr[11]; int main() { cin>>N; for(int i=0;i<N;i++){ cin>>arr[i].a>>arr[i].b>>arr[i].c; long long total = arr[i].a+arr[i].b; if(arr[i].a<0 && arr[i].b<0 && total>=0){ //发生溢出 cout<<"Case #"<<i+1<<": "<<"false"<<endl; }else if(arr[i].a>0 && arr[i].b>0 && total<=0){ cout<<"Case #"<<i+1<<": "<<"true"<<endl; }else{ if(total>arr[i].c){ cout<<"Case #"<<i+1<<": "<<"true"<<endl; }else{ cout<<"Case #"<<i+1<<": "<<"false"<<endl; } } } return 0; }
相关文章推荐
- 微信骗子 QQ7492593 电话 18627650031 死全家
- A. Coder
- A4纸的象素分辨率计算
- 在windows下 配置 tomcat6.0 开机自启动
- 找工作?该复习了!
- 模板编程 实例2 素数判定
- 修改php.ini配置PHP扩展模块教程
- 解决Struts2 json-plugin Date或Timestamp等日期格式带T的问题
- 关于”因为此版本的应用程序不支持其项目类型(.csproj)“错误的解决办法
- Dojo 的文档操作基础二<9>
- MVC应用程序中,怎样控制与复制相同的功能
- SQL计算实际工作日(天)及两个时间(工作日)间隔(小时)!
- 微信骗子 QQ7492593 电话 18627650031 这个骗子骗我4000块钱
- 数据结构--树
- 创建jquery扩展的几种方法
- ComboBox function(node,e),获取id和name
- 基于BCM53115实现ACL功能
- EL动态获取字段里的值
- Leetcode刷题笔录 Anagrams
- Ant