#include <bits/stdc++.h>
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)
using namespace std;
typedef long long ll;
typedef vector<int>vc;
int Int(string ss)
{
int su=0;
for(int i=ss.size()-1,j=0; i>=0; i--,j++)
{
su+=(ss[i]-'0')*pow(2,j);
}
return su;
}
string Tobin(string s)
{
string res;
// cout<<s<<endl;
string ss[]=
{
"0000", "0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"
};
for(int i=0; i<s.size(); i++)
{
int in;
if(s[i]>='0'&&s[i]<='9') in=(s[i]-'0');
else in=(int)(s[i]-55);
// cout<<in<<endl;
res+=ss[in];
}
return res;
}
int main()
{
// READ;
int test;
sc(test);
while(test--)
{
string a,b,c;
cin>>a>>b>>c;
string x=Tobin(a);
string y=Tobin(c);
int cc=13-x.size();
while(cc--) cout<<"0";
cout<<x;
cout<<" "<<b<<" ";
int ccc=13-y.size();
while(ccc--) cout<<"0";
cout<<y<<" = ";
int p=Int(x);
int q=Int(y);
// cout<<p<<" "<<q<<endl;
if(b[0]=='+') cout<<p+q<<endl;
else cout<<p-q<<endl;
}
return 0;
}
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)
using namespace std;
typedef long long ll;
typedef vector<int>vc;
int Int(string ss)
{
int su=0;
for(int i=ss.size()-1,j=0; i>=0; i--,j++)
{
su+=(ss[i]-'0')*pow(2,j);
}
return su;
}
string Tobin(string s)
{
string res;
// cout<<s<<endl;
string ss[]=
{
"0000", "0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"
};
for(int i=0; i<s.size(); i++)
{
int in;
if(s[i]>='0'&&s[i]<='9') in=(s[i]-'0');
else in=(int)(s[i]-55);
// cout<<in<<endl;
res+=ss[in];
}
return res;
}
int main()
{
// READ;
int test;
sc(test);
while(test--)
{
string a,b,c;
cin>>a>>b>>c;
string x=Tobin(a);
string y=Tobin(c);
int cc=13-x.size();
while(cc--) cout<<"0";
cout<<x;
cout<<" "<<b<<" ";
int ccc=13-y.size();
while(ccc--) cout<<"0";
cout<<y<<" = ";
int p=Int(x);
int q=Int(y);
// cout<<p<<" "<<q<<endl;
if(b[0]=='+') cout<<p+q<<endl;
else cout<<p-q<<endl;
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন