Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int decimal(int num)
- {
- int temp=num,sum=0,base=1;
- while(temp!=0)
- {
- num=temp%10;
- temp=temp/10;
- if(num!=0&&num==1)
- {sum=sum+num*base;}
- base=base*2;
- }
- return sum;
- }
- int main()
- {
- int T;
- cin>>T;
- int A,B,c,d;
- for(int i=0;i<T;i++)
- {
- cin>>A>>B;
- c=decimal(A);
- d=decimal(B); //cout<<c<<' '<<d<<endl;
- if(c==d)cout<<"Case "<<i+1<<": Same"<<endl;
- else if(c>d)cout<<"Case "<<i+1<<": A"<<endl; //Case 1: A
- else if(d>c)cout<<"Case "<<i+1<<": B"<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement