题意:求十六进制的a+b
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2057
思路:十六进制无负数,转化为十进制判断是否输出负号,在转化为十六进制输出
注意点:无
以下为AC代码:
Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
12676610 | 2015-01-10 13:06:19 | Accepted | 2057 | 0MS | 1208K | 1002 B | G++ | luminous11 |
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <list>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define read(f) freopen(f, "r", stdin)
#define write(f) freopen(f, "w", stdout)
using namespace std;
const double pi = acos(-1);
int main()
{
ios::sync_with_stdio( false );
long long a, b;
while ( cin >> hex >> a >> b ){
if ( ( a + b ) >= 0 )
cout << uppercase << hex << a + b << endl;
else
{
cout << '-';
cout << uppercase << hex << - ( a + b ) << endl;
}
}
return 0;
}