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. 使用ActionFilterAttribute实现MVC后台授权

    授权就是我们在用户未登录的情况下不允许访问一些页面,只有登录后才能进行访问一些页面. 在mvc中我们可以使用ActionFilterAttribute来进行授权验证来阻止一些未经授权的直接访问的页面. ...

  2. UWP Button添加圆角阴影(三)

    原文:UWP Button添加圆角阴影(三) Composition DropShadow是CompositionAPI中的东西,使用Storyboard设置某个属性,就是频繁的触发put_xxx() ...

  3. 【转】OAuth的改变

    原文地址:http://huoding.com/2011/11/08/126 去年我写过一篇<OAuth那些事儿>,对OAuth做了一些简单扼要的介绍,今天我打算写一些细节,以阐明OAut ...

  4. 深入理解String类

    1.String str = "eee" 和String str = new String("eee")的区别 先看一小段代码, public static v ...

  5. ubuntu下nodejs源码安装

    1.从github选择下载自己要安装的nodejs版本,https://github.com/nodejs/node/releases,我下载的版本是node-9.11.2.tar.gz 2.解压no ...

  6. ASP.NET 上传大文件(原创)

    问题描述 需要在网站中上传文件,但是当文件大小太大的时候IIS会拒绝连接,导致用户看到不友好的错误界面. 解决方法 1.服务器端处理 在globle.asax中的protected void Appl ...

  7. Hadoop 2.4.1+HBase 0.98.6.1 分布式安装

    参考:http://blog.csdn.net/wind520/article/details/39856353

  8. syslog之二:syslog协议及rsyslog服务全解析

    目录: <syslog之一:Linux syslog日志系统详解> <syslog之二:syslog协议及rsyslog服务全解析> <syslog之三:建立Window ...

  9. War文件部署

    其实,开始要求将源码压缩成War文件时,一头雾水! 公司项目要求做CAS SSO单点登录 也就是这玩意.... 其实war文件就是Java中web应用程序的打包.借用一个老兄的话,“当你一个web应用 ...

  10. nginx配置client_body_temp_path

    http://wiki.nginx.org/HttpCoreModule 中写道: 这里的client_body_temp_path是制定post上传的$_FILES上传的文件地址 后面的level1 ...