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 ...
随机推荐
- 它可以作为一个代理server或者转发java类
在项目中使用,这简化和通用汽车.突出的基本思路,细节可以基于此类改变. 基于java容器和servlet. package com.xxx.first; import java.io.Buffered ...
- 对于VS相关的插件
原文:对于VS相关的插件 本人使用这款IDE时间不长,但是很佩服其强大的功能. 编写代码时候的插件辅助,确实让人很舒服. 网上找了好多,有几个是很有用的,但是忘记了他们的网址,再次,总结下,也是给自己 ...
- hdu 1098 Ignatius's puzz
有关数论方面的题要仔细阅读,分析公式. Problem Description Ignatius is poor at math,he falls across a puzzle problem,so ...
- React.js终探(七)(完)
我们在前面介绍了组件的各种特性,这一节我们来说说多组件的情况. 在实际开发中,我们的组件难免会遇到有公共部分的情况,如果是个别情况还好,但如果数量比较多的话,那这时候,就需要公用了. 怎么公用呢? R ...
- 图解zookeeper FastLeader选举算法
zookeeper当配置为群集模式,在启动或异常情况将被选举为的例子Leader.默认选择算法FastLeaderElection. 不知道zookeeper够考虑这样一个问题:某个服务能够配置为多个 ...
- Android开源--MenuDrawer
开放的源地址:https://github.com/SimonVT/android-menudrawer 简单介绍:menudrawer是跟sliderMenu差点儿相同的一种框架,常被应用做设置界面 ...
- C#将Word,Excel与Html,PDF互转
public class OfficeHelper { /// <summary> /// word转成html /// </summary> /// <param na ...
- 【高德地图API】如何获得行政区域?如何制作行政规划图?
原文:[高德地图API]如何获得行政区域?如何制作行政规划图? 什么是行政规划图?如何获得每个行政区域的边界轮廓图?举例:重庆市 江北区.如图: 官方类参考:http://developer.amap ...
- Android[安德鲁斯] 文本Air Video 远程播放电脑视频
苹果iOS下列.目前应用Air Video,能力iOS由Wifi远程直接播放电脑视频,无需看视频复制到手机.非常好用!最近使用Android打电话.展望类别似应用,找了很长一段时间没有找到.在仔细的思 ...
- 流动python - 八皇后问题简单解决方案
思维: 使用DFS. 坐标的一维阵列的表达,在标行,元素列.A[i]=j它表示第一i女王就行了j柱. 以穿越线,由线(从上到下),决定其列(左到右),所以,不要推断冲突的行,和主斜线副斜线冲突. (行 ...