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(水题)的更多相关文章
- light oj 1354 - IP Checking
1354 - IP Checking PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB An I ...
- poj 2105 IP Address(水题)
一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...
- LightOJ - 1354 - IP Checking(进制)
链接: https://vjudge.net/problem/LightOJ-1354 题意: An IP address is a 32 bit address formatted in the f ...
- 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 ...
- lightoj--1354-- IP Checking(水题)
IP Checking Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Sta ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- D - 楼下水题(kmp+Manacher)
D - 楼下水题 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Statu ...
- BZOJ USACO 银组 水题集锦
最近刷银组刷得好欢快,好像都是水题,在这里吧他们都记录一下吧(都是水题大家一定是道道都虐的把= =)几道比较神奇的题到时再列出来单独讲一下吧= =(其实我会说是BZOJ蹦了无聊再来写的么 = =) [ ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
随机推荐
- ListView中响应item的点击事件并且刷新界面
---恢复内容开始--- 最近在在实现listview功能中遇到了这个问题: 点击事件写在了adapter的item中,不知道如何在listview的点击事件中更新数据的显示: 总结:1.要使用not ...
- 第八章 C#面向对象编程(Object-Oriented Programming,OOP)简介
.NET OOP 一.面向对象编程的含义 1.函数(过程化)编程常常导致单一的应用程序,即所有的功能都包含在几个代码模块中(常常是一个代码模块) 而使用OOP技术,常常使用许多代码模块,每个模块提供特 ...
- DevOps探索
devops最近随着docker的升温而被越来越多的人所吸引!最近因项目所需投身到devops的项目当中,经过初步的实践搞出一套 paas平台的devops,这个平台现在还需要检验! 作为一个dev, ...
- MVC中关于JSON的处理
jquery中提交数据 $.getJSON("/TopicUpdate/UpdateInformation", { "bookId": bookid } ...
- ORA-02396: exceeded maximum idle time, please connect again的原因
一般为了防止过多活动的session占用资源,可以对允许连接到数据库的session个数,已连接到数据库的session空闲时间等进行限制(当然也可以对尝试连接次数等其它很多内容进行限制).方式就是可 ...
- PHP解析和生成xml(DOMDocument版)
上次和大家分享了SimpleXML操作xml的一些知识,但是php中除了simplexml还有DOMDocument,这次就着重来看看DOMDocument的用法,还是把生成xml和解析xml分开写 ...
- ES6学习笔记:Module的基本用法
export和import ES6实现了模块功能,试图解决JavaScript代码上的依赖和部署上的问题,取代现有的CommonJs的AMD规范,成为浏览器和服务器通用的模块解决方案. 模块功能有两个 ...
- 设计模式的PHP实现示例(转)
symfony2 很多设计模式思想,下面的资料会有点帮助:http://www.open-open.com/lib/view/open1414996676559.html 阅读目录 Creationa ...
- MVC-05 Model(1)
在开发应用程序的过程中,经常需要处理许多大大小小的数据,例如,SQL Server数据库存取.连接AD(Active Directory)数据库进行验证.调用外部Web Service取得数据等.除了 ...
- [Windows编程] #pragma once 和#ifndef ... #define ... #endif 比较
C++中防止头文件被多次include 的常见方式有: 1) 用#ifndef ... #define ... #endif 宏 #ifndef __MYHEADER_H__#define __M ...