1354 - IP Checking
Time Limit: 2 second(s) Memory Limit: 32 MB

An IP address is a 32 bit address formatted in the following way

a.b.c.d

where a, b, c, d are integers each ranging from 0 to 255. Now you are given two IP addresses, first one in decimal form and second one in binary form, your task is to find if they are same or not.

Input

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

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

Output

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

Sample Input

Output for Sample Input

2

192.168.0.100

11000000.10101000.00000000.11001000

65.254.63.122

01000001.11111110.00111111.01111010

Case 1: No

Case 2: Yes

题解:写一下就过了

代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
const int INF=0x3f3f3f3f;
char s1[],s2[];
int main(){
int T,cnt=,l1,l2;
int a[],b[];
scanf("%d",&T);
while(T--){
scanf("%s%s",s1,s2);
l1=strlen(s1);l2=strlen(s2);
int temp=,k=;
for(int i=;i<l1;i++){
if(s1[i]=='.')a[k++]=temp,temp=;
else temp=temp*+s1[i]-'';
}
a[k++]=temp;
temp=;k=;
for(int i=;i<l2;i++){
if(s2[i]=='.')b[k++]=temp,temp=;
else temp=temp*+s2[i]-'';
}
b[k++]=temp;
int flot=;
for(int i=;i<;i++){
if(a[i]!=b[i])flot=;
}
if(flot)printf("Case %d: Yes\n",++cnt);
else printf("Case %d: No\n",++cnt);
}
return ;
}

1354 - IP Checking(水题)的更多相关文章

  1. light oj 1354 - IP Checking

    1354 - IP Checking   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB An I ...

  2. poj 2105 IP Address(水题)

    一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...

  3. LightOJ - 1354 - IP Checking(进制)

    链接: https://vjudge.net/problem/LightOJ-1354 题意: An IP address is a 32 bit address formatted in the f ...

  4. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A. Checking the Calendar 水题

    A. Checking the Calendar 题目连接: http://codeforces.com/contest/724/problem/A Description You are given ...

  5. lightoj--1354-- IP Checking(水题)

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

  6. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  7. D - 楼下水题(kmp+Manacher)

    D - 楼下水题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Statu ...

  8. BZOJ USACO 银组 水题集锦

    最近刷银组刷得好欢快,好像都是水题,在这里吧他们都记录一下吧(都是水题大家一定是道道都虐的把= =)几道比较神奇的题到时再列出来单独讲一下吧= =(其实我会说是BZOJ蹦了无聊再来写的么 = =) [ ...

  9. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

随机推荐

  1. 自定义通用Distinct去除重复数据的2中方式

    由于Lambda Distinct方法默认是按照集合里面的值比较的,所以当集合里面存放的是类的时候,我们一般是按照实体中的某一属性值比较,其实是用默认的Distinct也可以的,自己先定义一个实现了接 ...

  2. JavaScript使用button提交表单

    <form action="test.html" method="POST"> <input type="button" ...

  3. Android应用开发基础篇(5)-----Handler与多线程

    链接地址:http://www.cnblogs.com/lknlfy/archive/2012/02/19/2358155.html 一.概述 Handler这个类主要用来发送和处理消息的.它有多个发 ...

  4. C#中网站根路径、应用根路径、物理路径、绝对路径,虚拟路径的区别

    C#中网站根路径,请站点的最外一层 /表示 应用根路径 ~/表示,有时候C#程序路径并不是网站路径 物理路径 server.mappath("~/") 是指应用程序放在服务器硬盘的 ...

  5. OpenGL: 环境配置和图元的绘制

    前言 距离上一篇博客已经过去一个半月了,这段时间过得确实充实,虽然一大段时间泡在图书馆复习,但至少也能学到点东西.跨年晚和元旦一整天,全身心投入图形学小课设的编程,终于实现了老师要求的所有功能,回想起 ...

  6. PHP_Yii框架_专辑<一>

    一.PHP主流框架 cakephp—速度比较慢.CI(codeIgniter)—小型.symfony. TP(thinkphp)—国人开发.小型.zendframework(官方)—大型 Yii: 特 ...

  7. CRM中直接创建SAP订单的实施方案记录

    后台生成订单按钮JS do_alert('正在生成SAP订单,暂停所有操作,同时请不要关闭本窗口!'); var hefid = clientData.urlArgs.entityId; var ur ...

  8. 1_HelloWorld

    学iOS开发与学Swift是两件事情,Swift只是一种语言,它有官方手册,里面包含了全部的语法.对其他任何一门语言很熟悉的人,学习Swift可能只需要几天的时间.而这之后,学习iOS开发才是难点,有 ...

  9. char[]转换成wchar_t的转换方法(GNU Libc规定wchar_t为32位)

    wchar_t是C/C++的字符数据类型,是一种扩展的字符存储方式,wchar_t类型主要用在国际化程序的实现中,但它不等同于unicode编码.unicode编码的字符一般以wchar_t类型存储. ...

  10. Java并发编程总结2——慎用CAS(转)

    一.CAS和synchronized适用场景 1.对于资源竞争较少的情况,使用synchronized同步锁进行线程阻塞和唤醒切换以及用户态内核态间的切换操作额外浪费消耗cpu资源:而CAS基于硬件实 ...