Skip to content

Instantly share code, notes, and snippets.

@fardinabir
Created October 19, 2019 06:17
Show Gist options
  • Save fardinabir/261b73a1c09c08a00664426a8ebc7ec4 to your computer and use it in GitHub Desktop.
Save fardinabir/261b73a1c09c08a00664426a8ebc7ec4 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int b2i(string st)
{
int s=0,c=1,l=st.size();
for(int i=l-1;i>=0;i--)
{
if(st[i]=='1')
{
s+=c;
}
c*=2;
}
return s;
}
int main()
{
int t,k, tmp, i=1,j,l,m,n,x1,x2;
cin>>n;
getchar();
bool flag=true;
string st,stt,x,y;
while(i<=n)
{
flag=true;
printf("Case %d: ",i++);
getline(cin,st);
getline(cin,stt);
istringstream ss(st),sss(stt);
while(getline(ss,x,'.'))
{
x1=stoi(x);
getline(sss,y,'.');
if(b2i(y)!=x1)
{
flag=false;
cout<<"No"<<endl;
break;
}
}
if(flag)
{
cout<<"Yes"<<endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment