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

______________________________________________

题目解答:

 #include<stdio.h>
int main(){
long a,b,c;
while(scanf("%ld%ld",&a,&b) == ){
c = a - b;
if ( c < ) c = -c;
printf("%ld\n",c);
} return ;
}

注意点:

1.  输入的数据不大于2^32,32位系统或者是64位使用的int的表示范围为(-2^31)~(2^31-1)。使用long

2.  使用long可以accept,UVa平台使用的是64位的。在32位系统中long也是占4字节,不满足题目要求。

获取各数据类型所占字节数:我的电脑为64位的系统上:(使用sizeof(int))

#include<stdio.h>

int main(){
printf("short:%d\n",sizeof(short));
printf("signed int:%d\n",sizeof(signed int));
printf("unsigned int:%d\n",sizeof(unsigned int));
printf("long:%d\n",sizeof(long));
printf("long long:%d\n",sizeof(long long));
printf("double:%d\n",sizeof(double));
printf("float:%d\n",sizeof(float)); return ; }

运行结果得:

  short:2; int:4;unsigned int:4;long:8;long long:8;double:8;float:4

BTW:

MAC上面查看系统32还是64位的命令:

1.  在终端输入命令   ioreg -l -p IODeviceTree | grep "firmware-abi" | sed -e 's/[^0-9A-Z]//g'

输出:EFI64 ——64位
   输出:EFI32 ——32位

2.  打开终端,输入命令 uname -a 回车

x86_64 ——64位

i686 ——表示系统32位的

10055 - Hashmat the Brave Warrior & 各数据类型所占字节数 (C语言)的更多相关文章

  1. java基本数据类型所占字节数

    JAVA基本数据类型所占字节数是多少?(32位系统) byte     1字节                short    2字节                int      4字节      ...

  2. 10055 - Hashmat the Brave Warrior

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

  3. 转:C/C++基本数据类型所占字节数

    参考:http://blog.csdn.net/vast_sea/article/details/8076934 关于这个基本的问题,很早以前就很清楚了,C标准中并没有具体给出规定那个基本类型应该是多 ...

  4. C/C++基本数据类型所占字节数

    关于这个主要的问题,非常早曾经就非常清楚了,C标准中并没有详细给出规定那个基本类型应该是多少字节数,并且这个也与机器.OS.编译器有关,比方相同是在32bits的操作系统系,VC++的编译器下int类 ...

  5. JAVA基本数据类型所占字节数是多少?

    byte     1字节                short    2字节                int      4字节                long     8字节     ...

  6. C、C++数据类型所占字节数

    C标准中并没有详细给出规定那个基本类型应该是多少字节数.详细与机器.OS.编译器有关,比方相同是在32bits的操作系统系,VC++的编译器下int类型为占4个字节:而tuborC下则是2个字节. 所 ...

  7. UVa 10055 - Hashmat the Brave Warrior

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

  8. java 8种基本数据类型的默认值及所占字节数

    通过一段代码来测试一下 8种基本数据类型的默认值 package dierge; public class Ceshi { int a; double b; boolean c; char d; fl ...

  9. java中8种数据类型和默认值所占字节数

    java 8种基本数据类型的默认值及所占字节数 通过一段代码来测试一下 8种基本数据类型的默认值 1 package dierge; 2 3 public class Ceshi { 4 int a; ...

随机推荐

  1. poj1228 Grandpa's Estate

    地址:http://poj.org/problem?id=1228 题目: Grandpa's Estate Time Limit: 1000MS   Memory Limit: 10000K Tot ...

  2. MOPSO 多目标粒子群优化算法

    近年来,基于启发式的多目标优化技术得到了很大的发展,研究表明该技术比经典方法更实用和高效.有代表性的多目标优化算法主要有NSGA.NSGA-II.SPEA.SPEA2.PAES和PESA等.粒子群优化 ...

  3. uva1291

    这题说的给了 一 个 图,每次 按照他给的顺序 跳格子 给了 每种 格子之间的 转换 代价 求最后 转换代价 dp[i][j] 表示 左脚在i 右脚 在j 的最小代价 然后用滚动数组 ,就可以不断说的 ...

  4. 什么是Java泛型?

    ①为什么要使用泛型? 引入例子 public class GenericTest { public static void main(String[] args) { List list = new ...

  5. Object-C开发之instancetype和id关键字

    一.什么是instancetypeinstancetype是clang 3.5开始,clang提供的一个关键字,表示某个方法返回的未知类型的Objective-C对象.我们都知道未知类型的的对象可以用 ...

  6. Django学习笔记之form组件的局部钩子和全局钩子

    本文通过注册页面的form组件,查看其中使用的全局钩子和局部钩子. # Create your views here. class RegForm(forms.Form): username = fo ...

  7. STM32时钟树

    STM32的时钟系统 相较于51单片机,stm32的时钟系统可以说是非常复杂了,我们现在看下面的一张图: 上图说明了时钟的走向,是从左至右的从时钟源一步步的分配给外设时钟.需要注意的是,上图左侧一共有 ...

  8. Linux 中各个文件夹的作用

    /  根目录 包含了几乎所的文件目录.相当于中央系统.进入的最简单方法是:cd /. /boot  引导程序,内核等存放的目录 这个目录,包括了在引导过程中所必需的文件.在最开始的启动阶段,通过引导程 ...

  9. 导入tensorflow:ImportError: libcublas.so.9.0: cannot open shared object file: No such file or director【转】

    本文转载自:https://blog.csdn.net/ksws0292756/article/details/80034086 版权声明:本文为博主原创文章,转载请一定附上博主原文链接,并署名转自Z ...

  10. HDU1510 White rectangles( 乱搞 O(n^3) )题解

    思路: 友谊赛的时候一直想到了,但是没想出来怎么遍历才能找到所有矩阵,卡住了. 这里讲一下完整思路:我们用一个num[i][j]表示第i行第j列每一列连续的白色格子数量,然后我们定义一个MIN,并且每 ...