码迷,mamicode.com
首页 > 其他好文 > 详细

HDU2057

时间:2017-03-17 14:37:38      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:while   lan   输出   php   fine   http   get   处理   比较   

http://acm.hdu.edu.cn/showproblem.php?pid=2057

涉及到16进制内的加法,可以用%I64x直接来处理,要注意到16进制中负数是用补码来表示的。一个比较困惑的事实是,这道题再输出时,%64X中‘X’必须是大写,小写是过不了的。

注意:__int64 %I64X ,输出用大写

#include "cstdio"

int main()
{
    __int64 a,b,c;
    while(~scanf("%I64X%I64X",&a,&b))
    {
        c=a+b;
        if(c>=0)
            printf("%I64X\n",c);
        else
            printf("-%I64X\n",-c);
    }
    return 0;
}

 

#include "cstdio"

#define LL long long
int main()
{
    LL a,b,c;
    while(~scanf("%llX%llX",&a,&b))
    {
        c=a+b;
        if(c>=0)
            printf("%llX\n",c);
        else
            printf("-%llX\n",-c);
    }
    return 0;
}

 

HDU2057

标签:while   lan   输出   php   fine   http   get   处理   比较   

原文地址:http://www.cnblogs.com/kimsimple/p/6565767.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!