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

注意:

1.  vice versa  译为 反之亦然
2.  用c++ 提交  int64 不能被识别 会有编译错误。。。。PE两次。。
3.  用 long 或 long long 或者 double 类型 都可以满足数据 范围

#include<stdio.h>
//vice versa反之亦然,坑爹!还有为啥int64不能用?
int main()
{
long a,b;
while(scanf("%ld%ld",&a,&b)!=EOF)
{
if(b>a)
printf("%ld\n",(b-a));
else
printf("%ld\n",(a-b));
}
return ;
} 这道题我可耻的错了3次,真心跪了,有一个陷阱: 我坚定的认为 unsigned int 能够实现2^ !!!!
事实上,这是错的,unsigned int 的确能够代表 ^32个数,但是最高的那个数是 ^-。所以应该要用long long,但是不知道为什么long 也可以,原来
C++标准只规定int型数据所占的字节数不大于long型,不小于short型。
16位平台 32位平台 64位平台
char 1个字节8位 char 1个字节8位 char 1个字节8位
short 2个字节16位 short 2个字节16位 short 2个字节16位
int 2个字节16位 int 4个字节32位 int 4个字节32位
long 4个字节32位 long 4个字节32位 long 8个字节64位
指针 2个字节 long long 8个字节64位 long long 8个字节64位
指针 4个字节32位 指针 8个字节 64位 所以用哪个数据类型,得自己掂量掂量。幸好这个Uva是用64位的系统,否则我的long又得WA一次。
总结:()看清楚题目,认真学习英语:vice versa == 反之亦然
()unsigned int 能代表2^32个数,但是最高的那个数是2^-
()long long 是linux 下的,int64是windows下的,一般的OJ是linux下run

Hashmat the brave warrior(UVa10055)简单题的更多相关文章

  1. Hashmat the brave warrior - UVa10055

    欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10055.html 题目描述 Pr ...

  2. 10055 - Hashmat the Brave Warrior

    Problem A Hashmat the brave warrior Input: standard input Output: standard output Hashmat is a brave ...

  3. 10055 - Hashmat the Brave Warrior & 各数据类型所占字节数 (C语言)

    Problem A Hashmat the brave warrior Input: standard input Output: standard output Hashmat is a brave ...

  4. UVa 10055 - Hashmat the Brave Warrior

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...

  5. 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 ...

  6. BZOJ 2683: 简单题

    2683: 简单题 Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 913  Solved: 379[Submit][Status][Discuss] ...

  7. 【BZOJ-1176&2683】Mokia&简单题 CDQ分治

    1176: [Balkan2007]Mokia Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 1854  Solved: 821[Submit][St ...

  8. Bzoj4066 简单题

    Time Limit: 50 Sec  Memory Limit: 20 MBSubmit: 2185  Solved: 581 Description 你有一个N*N的棋盘,每个格子内有一个整数,初 ...

  9. Bzoj2683 简单题

    Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 1071  Solved: 428 Description 你有一个N*N的棋盘,每个格子内有一个整数, ...

随机推荐

  1. jQuery基础(3)- ajax

    一.jQuery的ajax 1.什么是ajax AJAX = 异步的javascript和XML(Asynchronous Javascript and XML). 简言之,在不重载整个网页的情况下, ...

  2. cad.net之ACAD和GCAD环境变量获取

    #if AC2006 || AC2007 || AC2008 || AC2009 || AC2010 || AC2011 || AC2012 [System.Security.SuppressUnma ...

  3. zookeeper安装小记

    做了5个节点,但是查看状态的时候,发现 ./zkServer.sh statusJMX enabled by defaultUsing config: /opt/zookeeper/bin/../co ...

  4. 【转】如何用css限制文字长度,使溢出的内容用省略号…显示

    文章转自这里(现在貌似被黑了,建议不要点击了) ps:因在该地方没看到转载按钮,复制下存到这里以待自己方便,别人能看到帮助一下更是乐意之至,效果亲测可以实现,兼容IE.谷歌.火狐 由于文字内容长度的不 ...

  5. js转换数据格式为货币格式

    有时候输资金数据的时候如果位数较多就不好读了,如果输完能转换一下格式,转成用“,”隔开的通用格式就比较好看了.自己写了一个备用,以后用到的话就不用再写了. //将数字转换为货币格式,用,隔开 func ...

  6. d3.js在vue项目中的安装及案例

    1. 安装: npm i d3 --save 2. 引入:main.js import * as d3 from "d3"; Vue.prototype.$d3 = d3; win ...

  7. 【并发】3、LockSupport阻塞与唤醒,相较与wait和notify

    我们可以使用wait和notify分别对象线程进行阻塞或者唤醒,但是我们也可以使用LockSupport实现一样的功能,并且在实际使用的时候,个人感觉LockSupport会更加顺手 范例1,wait ...

  8. Flask 微博三方登录

    1.进入微博开发平台(https://open.weibo.com/),注册账号,填写开发者信息 2.创建应用.创建应用完成后,可以在"我的应用 - 应用信息"中查看您所创建应用的 ...

  9. vue教程2-02 vue防止花括号{{}}闪烁,v-text和v-html、v-cloak

    vue教程2-02 vue防止花括号{{}}闪烁,v-text和v-html.v-cloak 一.v-text和v-html <span>{{msg}}</span>  --& ...

  10. 全网最全的Windows下Python2 / Python3里正确下载安装用来向微信好友发送消息的itchat库(图文详解)

    不多说,直接上干货! 建议,你用Anaconda2或Anaconda3. 见 全网最全的Windows下Anaconda2 / Anaconda3里正确下载安装用来向微信好友发送消息的itchat库( ...