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. C#实时检测端口占用情况

    在TCP/IP协议中,服务端需要去监听客户端的端口,开始监听,我们需要检测使用的端口是否被占用,获取系统当前使用的所有端口号,用此端口进行匹配即可. 代码如下 internal static Bool ...

  2. LOJ#3093. 「BJOI2019」光线(递推+概率期望)

    题面 传送门 题解 把\(a_i\)和\(b_i\)都变成小数的形式,记\(f_i\)表示\(1\)单位的光打到第\(i\)个玻璃上,能从第\(n\)个玻璃下面出来的光有多少,记\(g_i\)表示能从 ...

  3. drf-序列化器的理解

    序列化器作用:  1.进行数据的校验 2.对数据对象进行转换 序列化:  模型类对象  ----->  python字典    用于输出, 返回给前端使用 反序列化:  前端传送的数据  --- ...

  4. tomcat服务的启动与隐藏启动(win)

    一:  tomcat的启动与隐藏启动 1. 正常启动:D:\apache-tomcat-8.5.24\bin中的   startup.bat  双击启动 2. 启动tomcat服务后,window下方 ...

  5. POJ 2562

    #include<iostream> #include<algorithm> #define MAXN 15 using namespace std; //int rec[MA ...

  6. mac操作记录

    1.mac'主目录地址' 类似我的电脑 点桌面空白处按shift+command+C, 双击Macintosh HD图标后就能看见system文件夹 2.做excel表格,下载Microsoft Of ...

  7. odoo开发笔记 -- 模型一对多tree视图弹窗效果实现

    实现效果参考: 1. 开发者模式 -- 设置 -- 工作流 -- 编辑 -- 添加项目 2. 会计模块 -- 管理 -- 付款条款 -- 编辑/创建 实现方式,很简单.只要视图界面写个一对多关联字段就 ...

  8. Prototype原型模式(创建型模式)

    1.原型模式解决的问题 现在有一个抽象的游戏设施建造系统,负责构建一个现代风格和古典风格的房屋和道路. 前提:抽象变化较慢,实现变化较快(不稳定) 整个抽象的游戏设施建造系统相对变化较慢,本例中只有一 ...

  9. android的电话监听

    android的电话监听 新建一个项目,结构图如下: PhoneService: package com.demo.tingdianhua; import android.app.Service; i ...

  10. 使用mysql workbench和vscode进行数据库差异比对

    按照如图步骤,导出正式服务器的数据库和测试服务器数据库,并按照指定格式命名. 在vscdoe的文件列表下选中待比较文件1,右键-选择以进行比较. 然后选中第二文件,右键-与已选择文件比较