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

 #include <stdio.h>
#include <math.h>
int main()
{
long long a, b;
for (;scanf("%lld%lld", &a, &b) != EOF;)
printf("%lld\n", a < b ? b - a : a - b);
return ;
}

报告:本题原以为能很容易应付,结果做了两天都没做出来,最后还是参考网上的才完成,现在说下做题出现的问题:1,没看清题意,对or vice versa这个没理解,便理所当然的把第一个当作小于第二个的数。2,2的32次方应用long long来声明定义,却用了int,没理解给出数的范围的意思,其中也暴露了我没理解int型等数据类型的取值范围。3,EOF为CTRL+Z而不是CTRL+C,导致一直出错。

原因:1,英语不熟,且粗心大意,看了个大概便做题。2理所当然了,对数据类型的不熟悉。3对文件相关标志并不理解

解决:1,只能靠学英语解决。暂无解决 。2,int型当是2个字节时,一个字节为8位,则范围是2的-15次方到2的15次方,同理,long long型是8个字节时,则范围是2的-63次方到2的63次方,至于浮点数,暂先不涉猎。3,EOF即end of file,因为文本存储方式为ascii码,则范围为0~255,不存在-1,EOF表-1,返回EOF即表结束,在windows下为CTRL+Z,而linux下则是CTRL+D。

UVa OJ 10055的更多相关文章

  1. uva oj 567 - Risk(Floyd算法)

    /* 一张有20个顶点的图上. 依次输入每个点与哪些点直接相连. 并且多次询问两点间,最短需要经过几条路才能从一点到达另一点. bfs 水过 */ #include<iostream> # ...

  2. UVa OJ 194 - Triangle (三角形)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 A triangle is a basic shape of planar geometry. It con ...

  3. UVa OJ 175 - Keywords (关键字)

    Time limit: 3.000 seconds限时3.000秒 Problem问题 Many researchers are faced with an ever increasing numbe ...

  4. UVa OJ 197 - Cube (立方体)

    Time limit: 30.000 seconds限时30.000秒 Problem问题 There was once a 3 by 3 by 3 cube built of 27 smaller ...

  5. UVa OJ 180 - Eeny Meeny

    Time limit: 3.000 seconds限时3.000秒 Problem问题 In darkest <name of continent/island deleted to preve ...

  6. UVa OJ 140 - Bandwidth (带宽)

    Time limit: 3.000 seconds限时3.000秒 Problem问题 Given a graph (V,E) where V is a set of nodes and E is a ...

  7. 548 - Tree (UVa OJ)

    Tree You are to determine the value of the leaf node in a given binary tree that is the terminal nod ...

  8. UVa OJ 10300

    Problem A Ecological Premium Input: standard input Output: standard output Time Limit: 1 second Memo ...

  9. UVa OJ 10071

    Problem B Back to High School Physics Input: standard input Output: standard output A particle has i ...

随机推荐

  1. C#UDP同步实例

    差不多有一个礼拜总算有点进步. 代码很简单,只是为了实现功能. 网络上的资源是很多,除了不能用的,就是抄来抄去,是在乏味浪费时间. 说一下代码背景:实现的功能是发送端发送消息,接收端接收后立即响应,发 ...

  2. 关于Windows Azure 地缘组(Affinity Groups)

    最近在和一些客户和朋友的沟通中,发现Windows Azure地缘组概念很少有了解.我的建议是使用地缘组来优化同一区域内的网络访问速度.如果我的说法有误,欢迎大家指正. 关于“地缘组”的概念(摘自MS ...

  3. Windows 7 不同安装模式简要区别(图解)

    ★ 你可能对GHOST不支持AHCI感到迷惑,实际上,写过GHOST一键安装批处理的都知道一个叫FINDCD.EXE的小程序,可是这个程序老 了,AHCI模式光驱他找不到了,找不到光驱动意味着光盘中G ...

  4. winform 映射字段的写法:

    public partial class FrmFieldMapping : DevComponents.DotNetBar.Office2007Form { private AMDataFieldC ...

  5. Telnet连接Win7系统被拒绝的原因及解决方法

    有时要与计算机进行远程连接,会用到telnet.win7中telnet默认是没有开启的,所以这时连接会连接失败,其失败提示如下: 正在连接192.168.100.103...无法打开到主机的连接. 在 ...

  6. POJ3345

    http://poj.org/problem?id=3345 大意: 大意是说现在有n个城市来给你投票,你需要至少拿到m个城市的赞成票.想要获得第i个城市的赞成需要花费w[i],有个条件就是某些城市是 ...

  7. 关于完成端口IOCP异步接收连接函数AcceptEx注意事项

    AcceptEx方法有一个参数dwReceiveDataLength,指明了在收到连接后是否需要收到第一包数据才返回.需要注意的是,如果 dwReceiveDataLength=0,则当接收到一个连接 ...

  8. How Tomcat Works(二)

    我们这些可怜虫,只有沿着大神的思路,这样我们才能进步得更快:因为我们不是跟大神处于同一级别上.所以我这里是参考<How Tomcat Works>这本英文版的大作来理解tomcat的工作原 ...

  9. C#中的Collection 2

    Core Generic interface IEnumerable<T>:you can interate my elemnts, no need to know the count, ...

  10. bootStrap modal无法滚动处理

    bug:在大显示器上,模态框无法滚动,改变浏览器窗口大小,模态框可以滚动. 处理:模态框显示后,执行resize.或者直接调用handleUpdate 'shown.bs.modal #orderDe ...