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 ;
}

最新文章

  1. 前端开发:css基础知识之盒模型以及浮动布局。
  2. Postgresql 取随机数
  3. hibernate复合主键
  4. mac与php环境
  5. 我的WCF学习与强化系列文章
  6. UVa 1339,紫书P73,词频
  7. kali系统安装图文教程
  8. Ionic Android开发环境搭建 下
  9. 01-05-01-1【Nhibernate (版本3.3.1.4000) 出入江湖】延迟加载及其class和集合(set、bag等)的Lazy属性配置组合对Get和Load方法的影响
  10. [SQL Server系] -- 基本概念
  11. LeetCode题解——Regular Expression Matching
  12. StudentSchema student实例数据库环境搭建
  13. 转:LR的响应时间与使用IE所感受时间不一致的讨论
  14. 测试开发Python培训:实现屌丝的黄色图片收藏愿望(小插曲)
  15. js vue 请求
  16. 史上最简单的SpringCloud教程 | 第五篇: 路由网关(zuul)
  17. Swagger UI 与SpringMVC的整合
  18. Red5视频流服务器安装
  19. 云服务设置多台tomcat开机自启动
  20. ftp命令大全

热门文章

  1. objective-C学习笔记(十一)类别和扩展
  2. Java判断字符串是中文还是英文
  3. hadoop 主节点存储告警
  4. C++模板:二分查找
  5. 《UNIX环境高级编程》笔记--UNIX标准化及实现
  6. grunt用来压缩前端脚本
  7. http协议与http代理
  8. vs2010经常使用快捷键
  9. CSS+DIV标签命名规范 搜索引擎最喜欢
  10. android 中文 api (72) —— BluetoothSocket[蓝牙]