Hashmat the brave warrior - UVa10055
欢迎访问我的新博客:http://www.milkcu.com/blog/
原文地址:http://www.milkcu.com/blog/archives/uva10055.html
题目描述
Problem A
Hashmat the brave warrior
Input: standard input
Output: standard output
Hashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before fighting he just calculates one thing, the difference between his soldier number and the opponent's soldier number. From
this difference he decides whether to fight or not. Hashmat's soldier number is never greater than his opponent.
Input
The input contains two integer numbers in every line. These two numbers in each line denotes the number of soldiers in Hashmat's army and his opponent's army or vice versa. The input numbers are not greater than 2^32. Input is terminated by End of File.
Output
For each line of input, print the difference of number of soldiers between Hashmat's army and his opponent's army. Each output should be in seperate line.
Sample Input:
10 12
10 14
100 200
Sample Output:
2
4
100
___________________________________________________________________________________
Shahriar Manzoor
16-12-2000
解题思路
注意32位整数的范围,使用无符号整数或64位整数。
一道非常简单的题,答案为什么总是错误的呢?
These two numbers in each line denotes the number of soldiers in Hashmat's army and his opponent's army orvice versa.
注意vice versa”,反之亦然。但是还是无法通过。
通过多次试验,发现绝对值函数abs()竟然在<algorithm> 头文件中。
代码实现
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void) {
long long a, b;
while(cin >> a >> b) {
cout << abs(b - a) << endl;
}
return 0;
}
(全文完)
Hashmat the brave warrior - UVa10055的更多相关文章
- Hashmat the brave warrior(UVa10055)简单题
Problem A Hashmat the brave warrior Input: standard input Output: standard output Hashmat is a brave ...
- 10055 - Hashmat the Brave Warrior
Problem A Hashmat the brave warrior Input: standard input Output: standard output Hashmat is a brave ...
- 10055 - Hashmat the Brave Warrior & 各数据类型所占字节数 (C语言)
Problem A Hashmat the brave warrior Input: standard input Output: standard output Hashmat is a brave ...
- UVa 10055 - Hashmat the Brave Warrior
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...
- UVA_10055:Hashmat the brave warrior
Language:C++ 4.8.2 #include<stdio.h> int main(void) { long long int a, b; while(scanf("%l ...
- Zerojudge解题经验交流
题号:a001: 哈囉 背景知识:输出语句,while not eof 题号:a002: 簡易加法 背景知识:输出语句,while not eof,加法运算 题号:a003: 兩光法師占卜術 背景知识 ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- UVa OJ 10055
Problem A Hashmat the brave warrior Input: standard input Output: standard output Hashmat is a brave ...
- 【索引】Volume 0. Getting Started
AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 0. Getting Started 10055 - Hashmat the Brav ...
随机推荐
- springMVC3得知(五岁以下儿童)--MultiActionController
Spring为了提供一个多动作控制器,您可以使用它的几个行动统一到一个控制器,这可以放在一起功能. 多动作控制器存在在一个单独的包中--org.springframework.web.mvc.mult ...
- SQL导入txt以及SQL中的时间格式操作
原文:SQL导入txt以及SQL中的时间格式操作 MySQL中导入txt的指令为: load data local infile "路径名称" into table "表 ...
- java安全编程
java安全程序实际上是一个点稍微防御性编程意味着内,竟java作为编程语言,较C,c++,本身被认为是比较安全的,随着C,C++这样的偏底层的编程语言比,java少了显示的指针调用.少了程序上的内存 ...
- 删RAC中间ASM和LISTENER
资源的正确方法
在我们的安装RAC什么时候.有时因各种错误加载错误ASM实例或LISTENER显示器,或增加CLUSTERWARE资源,但并没有真正的工作,例如: 如图所看到的,这里在2个节点分别创建过ASM1和AS ...
- jquery选择器中逗号的使用
1.多条件选择器 多条件选择器:$("p,div,span.menuitem"),同时选择p标签,div标签,和拥有menuitem样式的span标签元素 <table id ...
- Swift中文手册 -- The Basics
原文:Swift中文手册 -- The Basics 基础部分 Swift 是 iOS 和 OS X 应用开发的一门新语言.然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 S ...
- TRILL浅析
1 TRILL概述 TRILL的全称就是Transparent Interconnection of Lots of Links,顾名思义,其本质就是将非常多条链路透明地组织在一起,以致于上层IP应用 ...
- 突破IP限制动态替换代理ip。
须要导入的两个jar包 实现的javabean <span style="font-size:18px;">package com.jx.po; public clas ...
- STL慎重选择删除元素的
一.要删除容器中有特定值的全部对象 1.假设容器是vector.string或deque.则使用erase-remove习惯使用方法.比如: vector<int> c; c.era ...
- hdu1047 Integer Inquiry 多次大数相加
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047 Problem ...