Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef unsigned long long int ull;
- typedef long long int ll;
- typedef vector<int> vi;
- typedef vector<ll> vll;
- typedef vector<vi> vvi;
- typedef pair<int,int > pii;
- typedef vector< pii > vpii;
- typedef set<int> sti;
- #define sc scanf
- #define pf printf
- #define sci(n) scanf("%d",&n)
- #define scii(n,m) scanf("%d %d",&n,&m)
- #define scl(n) scanf("%lld",&n)
- #define scd(n) scanf("%lf",&n)
- #define scs(s) scanf("%s",s)
- #define pfi(n) printf("%d",n)
- #define pfl(n) printf("%lld",n)
- #define pff(n) cout<<n
- #define line printf("\n")
- #define spc printf(" ")
- #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
- #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
- #define cspf(i) printf("Case %d: ", i)
- #define pb push_back
- #define mp make_pair
- #define ff first
- #define ss second
- #define all(v) v.begin(),v.end()
- #define rall(v) v.rbegin(),v.rend()
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- /// Constants
- #define eps 1e-9
- #define PI acos(-1.0) // 3.1415926535897932
- #define MAX 1000009*/
- void fastIO()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- }
- int main()
- {
- //read();
- //write();
- map<char,string>mp = {{'0',"0000"},{'1',"0001"},{'2',"0010"},{'3',"0011"},{'4',"0100"},{'5',"0101"},{'6',"0110"},{'7',"0111"},{'8',"1000"},{'9',"1001"},{'A',"1010"},{'B',"1011"},{'C',"1100"},{'D',"1101"},{'E',"1110"},{'F',"1111"}};
- //for(auto x : mp) cout<<x.second<<' ';
- int t;
- sci(t);
- while(t--){
- string b1="0",b2="0",s;
- char c;
- int t1=0,t2=0;
- cin>>s;
- loop(i,1,3-s.size()){
- b1+="0000";
- }
- loop(i,0,s.size()-1){
- b1+=mp[s[i]];
- }
- cout<<b1<<' ';
- for(int i=b1.size()-1,j=1;i>=0;i--,j*=2){
- t1+=((b1[i]-'0')*j);
- }
- cin>>c;
- cout<<c<<' ';
- cin>>s;
- loop(i,1,3-s.size()){
- b2+="0000";
- }
- loop(i,0,s.size()-1){
- b2+=mp[s[i]];
- }
- cout<<b2<<" = ";
- for(int i=b2.size()-1,j=1;i>=0;i--,j*=2){
- t2+=((b2[i]-'0')*j);
- }
- if(c=='+') pfi(t1+t2);
- else pfi(abs(t1-t2));
- line;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement