Hashmat the brave warrior(UVa10055)简单题
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)简单题的更多相关文章
- Hashmat the brave warrior - UVa10055
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/uva10055.html 题目描述 Pr ...
- 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 ...
- BZOJ 2683: 简单题
2683: 简单题 Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 913 Solved: 379[Submit][Status][Discuss] ...
- 【BZOJ-1176&2683】Mokia&简单题 CDQ分治
1176: [Balkan2007]Mokia Time Limit: 30 Sec Memory Limit: 162 MBSubmit: 1854 Solved: 821[Submit][St ...
- Bzoj4066 简单题
Time Limit: 50 Sec Memory Limit: 20 MBSubmit: 2185 Solved: 581 Description 你有一个N*N的棋盘,每个格子内有一个整数,初 ...
- Bzoj2683 简单题
Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 1071 Solved: 428 Description 你有一个N*N的棋盘,每个格子内有一个整数, ...
随机推荐
- 网易免费企业邮箱Foxmail设置方法
网易免费企业邮箱Foxmail7.0设置方法 第一步:启动 Foxmail 邮件客户端,点击工具->账号管理,弹出如下页面. 点击新建,如下: 填写自己企业邮箱账号,然后下一步,邮箱类型选择PO ...
- 转载:TCP/IP四层模型
转载:TCP/IP四层模型 一. TCP/IP参考模型示意图 ISO制定的OSI参考模型的过于庞大.复杂招致了许多批评.与此对照,由技术人员自己开发的TCP/IP协议栈获得了更为广泛的应用. 如图所示 ...
- MySQL 主从复制相关参数
列举了MySQL主从复制主要的相关参数 binlog server_id 服务器在集群中唯一标识符 log_bin[=binlog_name] 启动二进制日志 log_bin_index 二进制日志索 ...
- Docker三剑客之Docker Compose
一.什么是Docker Compose Compose 项目是Docker官方的开源项目,负责实现Docker容器集群的快速编排,开源代码在https://github.com/docker/comp ...
- 01-02 notepad++安装、配置及使用
一.安装 按照默认设置,下一步下一步即可. 二.配置 设置-->首选项-->新建
- [Umbraco] 在umbraco中开发xlst的小窍门
当你在umbraco开发xslt时也可以调用C#里的方法,具体方法参考如下 点击第二个按钮 点击右侧的"Get Extensions" 系统自带了工具类,里面有很多常用也很实用的方 ...
- Eclipse个人规范化设置
为保证在各个在各个系统中获得的代码样式保持一致,规范法化开发,对Eclipse进行一些常用通用设置: 1. 代码块缩进 4个空格,如果使用 tab缩进,请设置成 1个 tab为 4个空格.(阿里巴巴开 ...
- ThreadLocal管理Connection
ThreadLocal管理Connection 每一个用户都对应有一个单独线程,每一个线程都有一个数据库连接对象Connection对象接待它. 一个用户对应一个线程,这个线程中的Connection ...
- StreamSets学习系列之StreamSets支持多种安装方式【Core Tarball、Cloudera Parcel 、Full Tarball 、Full RPM 、Docker Image和Source Code 】(图文详解)
不多说,直接上干货! Streamsets的官网 https://streamsets.com/ 得到 https://streamsets.com/opensource/ StreamSets支持多 ...
- 全网最详细的启动zkfc进程时,出现INFO zookeeper.ClientCnxn: Opening socket connection to server***/192.168.80.151:2181. Will not attempt to authenticate using SASL (unknown error)解决办法(图文详解)
不多说,直接上干货! at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:) at org ...