LightOJ-1354 IP Checking

Source: Internet
Author: User

IP Checking
Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld &%llu

Submit Status

Description

An IP address is a + bit address formatted in the following

A.b.c.d

Where A, B, C, D is integers each ranging from 0 to 255. Now you are given the IP addresses, first one in decimal form and second one in binary form, your task was to find if they is same or not.

Input

Input starts with an integer T (≤100), denoting the number of test cases.

Each case is starts with a lines. First line contains a IP address in decimal form, and second line contains a IP address in binary form. In binary form, each of the four parts contains 8 digits. Assume that the given addresses is valid.

Output

For each case, print the case number and "Yes" if they is same, otherwise print "No".

Sample Input

2

192.168.0.100

11000000.10101000.00000000.11001000

65.254.63.122

01000001.11111110.00111111.01111010

Sample Output

Case 1:no

Case 2:yes

Source

Problem Setter:jane Alam The number of days to pay attention to the cyclic termination conditions;
#include <cstdio>#include<cstring>intMain () {intc[5], d[5]; Chara[ +], b[ +]; intT, qt=1; scanf"%d", &t);  while(t--) {scanf ("%s%s", A, b); intIndexc=0, sum=0; intLena=strlen (a);  for(intI=0; i<=lena; i++)        {            if(a[i]=='.'|| i==Lena) {C[indexc++]=sum; sum=0; }            Elsesum=sum*Ten+a[i]-'0'; }                intIndexd=0, q=1; sum=0; intlenb=strlen (b);  for(inti=lenb-1; i>=-1; i--)         {            if(b[i]=='.'|| i==-1) {d[indexd++]=sum; Q=1; sum=0; }            Else{sum=sum+ (b[i]-'0') *p; Q*=2; }        }                inti;  for(i=0; i<4; i++)            if(C[i]! = d[3-i]) Break; printf ("Case %d:", qt++); if(i==4) printf ("yes\n"); Elseprintf ("no\n"); }}                         

LightOJ-1354 IP Checking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.