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. SQL Server索引进阶:第三级,聚集索引

    原文地址: Stairway to SQL Server Indexes: Level 3, Clustered Indexes 本文是SQL Server索引进阶系列(Stairway to SQL ...

  2. poj 2728 Desert King(最小比率生成树,迭代法)

    引用别人的解释: 题意:有n个村庄,村庄在不同坐标和海拔,现在要对所有村庄供水,只要两个村庄之间有一条路即可, 建造水管距离为坐标之间的欧几里德距离(好象是叫欧几里德距离吧),费用为海拔之差 现在要求 ...

  3. C++对象模型2--指针cout结果

    在开始之前,首先科普一下cout指针的知识,这样才能在测试程序中很好的理解: 看下面的代码: void main(void) { int a = 10; int *p = &a; cout & ...

  4. bzoj 1196: [HNOI2006]公路修建问题 二分+并查集

    题目链接 1196: [HNOI2006]公路修建问题 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1576  Solved: 909[Submit ...

  5. Qt实战之开发CSDN下载助手 (2)

    现在,我们正式开工啦.这一篇主要学习下基本的抓包分析.学会协议登录CSDN并制作登陆界面. 准备工具: 一款http抓包工具. 可以是FireBug或者fiddler.这里我们用httpWatch. ...

  6. perl unicode utf-8 \x转换

    [root@dr-mysql01 ~]# cat x5.pl use Encode; use JSON; use URI::Escape; use LWP::Simple; my $host = &q ...

  7. BZOJ 1058 报表统计 (STL)

    题解:数据结构的基本操作,用STL可以完美实现,就是比较慢…… #include <cstdio> #include <map> #include <set> #i ...

  8. HDU 2178 猜数字

    题解:设猜到的最大的数是h,在1到h间,你最多只要猜log2(h)+1(取整)次,所以易知==>h=2^m-1.即猜m次,能猜到的最大的数为2^m-1. #include <cstdio& ...

  9. dojo 学习笔记

    1  因为Dijit包括了一系列的UI组件,他绑定了4个支持的主题:nihilo, soria, tundra 和claro.每个主题包括了一系列的图片和CSS文件来控制组件的外观.CSS文件必须显示 ...

  10. 1005 - Rooks(规律)

    1005 - Rooks   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is ...