BINADD : DECEMBER CHALLENGE VIDEO EXPLANATION

This is my first ever video explanation. All doubts as well as suggestions are welcomed :grin:
Problem Statement :

Video Link :

Do visit!

2 Likes

//Can’t I do it this way …since i didnt know about the full adder approach.
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
#define quickio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace boost::multiprecision;
typedef long long ll;
cpp_int sum,c=0;
cpp_int bin(string s){ //to get decimal values of a and b
cpp_int res=0;
for(ll i=s.size()-1,j=0;i>=0;i–,j++){
if(s[i]==‘1’)
res+=(1<<j);
}
return res;
}
cpp_int add(string a,string b){
cpp_int A,B,U,V;
A=bin(a);
B=bin(b);
sum=A+B;
while(B>0){
++c;
U=A^B;
V=A&B;
A=U;
B=V*2;
}
return A;
}
int main(){
quickio();
string a,b,tmp;
vector< cpp_int > v;
cpp_int f;
ll t;
cin>>t;
while(t>0){
cin>>a;
cin>>b;
tmp=a+b;
f=add(a,b);
v.push_back©;
–t;
c=0;
}
for(auto x:v)
cout<<x<<"\n";
}