Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int bin(string n)
- {
- string num = n;
- int dec_value = 0;
- int base = 1;
- int len = num.length();
- for (int i = len - 1; i >= 0; i--)
- {
- if (num[i] == '1')
- dec_value += base;
- base = base * 2;
- }
- return dec_value;
- }
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- string s,s1;
- int a,b,cnt=0;
- cin>>s>>s1;
- a=bin(s);
- b=bin(s1);
- while(b!=0)
- {
- int U = a^b;
- int V = a&b;
- a = U;
- b = V * 2;
- cnt++;
- }
- cout<<cnt<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement