#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;
#define INF (1<<29)
#define SET(a) memset(a,-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define FILL(a,v) memset(a,v,sizeof(a))
#define PB push_back
#define FOR(i,n) for(int i = 0;i<n;i++)
#define PI acos(-1.0)
#define EPS 1e-9
#define MP(a,b) make_pair(a,b)
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define LL long long
string DecToBin(int number)
{
if ( number == 0 ) return "0";
if ( number == 1 ) return "1";
if ( number % 2 == 0 )
return DecToBin(number / 2) + "0";
else
return DecToBin(number / 2) + "1";
}
int main()
{
LL hex1,hex2,n,ans;
char c;
string s;
cin>>n;
while(n--)
{
cin>>hex>>hex1>>c>>hex>>hex2;
s=DecToBin(hex1);
stringstream ss;
ss<<s;
ss>>ans;
printf("%013lld %c ",ans,c);
s=DecToBin(hex2);
stringstream ss2;
ss2<<s;
ss2>>ans;
printf("%013lld = ",ans);
if(c=='-')
cout<<hex1-hex2<<endl;
else
cout<<hex1+hex2<<endl;
}
return 0;
}
No comments:
Post a Comment