IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 19125 | Accepted: 11053 | 
Description
is form by grouping 8 bits at a time and converting the binary representation to decimal representation. Any 8 bits is a valid part of an IP address. To convert binary numbers to decimal numbers remember that both are positional numerical systems, where the
first 8 positions of the binary systems are:
27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1
Input
Output
Sample Input
4
00000000000000000000000000000000
00000011100000001111111111111111
11001011100001001110010110000000
01010000000100000000000000000001
Sample Output
0.0.0.0
3.128.255.255
203.132.229.128
80.16.0.1
二进制转化
#include <cstdio>
#include <string.h>
#include <cmath>
#include <iostream>
#include <algorithm>
#define WW freopen("output.txt","w",stdout)
using namespace std;
int main()
{
char s[100];
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",s);
int len=strlen(s);
int a[5];
int sum=0,ans=1;
for(int j=1,i=len-1;i>=0;i--,j++)
{
if(j%8)
{
sum=(s[i]-'0')*ans+sum;
ans*=2;
}
else
{
sum=(s[i]-'0')*ans+sum;
ans=1;
a[j/8]=sum;
sum=0;
}
}
printf("%d.%d.%d.%d\n",a[4],a[3],a[2],a[1]);
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏的更多相关文章
- 迷之节约                                                       分类:            sdutOJ             最小生成树             2015-06-24 19:10    10人阅读    评论(0)    收藏
		迷之节约 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 FF超级有钱,最近又买了n个(1 <= n <= 300)小岛,为 ... 
- Hdu 1506 Largest Rectangle in a Histogram                                                    分类:            Brush Mode             2014-10-28 19:16    93人阅读    评论(0)    收藏
		Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ... 
- 二分图匹配                                                    分类:            ACM TYPE             2014-10-01 19:57    94人阅读    评论(0)    收藏
		#include<cstdio> #include<cstring> using namespace std; bool map[505][505]; int n, k; bo ... 
- Can you find it?                                                    分类:            二分查找             2015-06-10 19:55    5人阅读    评论(0)    收藏
		Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ... 
- 菊花加载第三方--MBprogressHUD                                                    分类:            ios技术             2015-02-05 19:21    120人阅读    评论(0)    收藏
		上次说到了网络请求AFN,那么我们在网络请求的时候,等待期间,为了让用户不认为是卡死或程序出错,一般都会放一个菊花加载,系统有一个菊花加载类叫UIProgressHUD.但是我今天要说的是一个替代它的 ... 
- iOS自定义字体及类目                                                    分类:            ios技术             2015-05-15 16:34    195人阅读    评论(0)    收藏
		1:获取字体文件 从各种渠道下载字体文件ttf, 网站或者从别的ipa里扣出来.(以fzltxh.ttf为例) 2:将fzltxh.ttf文件拷贝到工程中 3:在Info.plist中添加项: Fon ... 
- 多校3- RGCDQ                                                       分类:            比赛             HDU             2015-07-31 10:50    2人阅读    评论(0)    收藏
		RGCDQ Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practic ... 
- 【solr专题之三】Solr常见异常                                                    分类:            H4_SOLR/LUCENCE             2014-07-19 10:30    3223人阅读    评论(0)    收藏
		1.RemoteSolrException: Expected mime type application/octet-stream but got text/html 现象: SLF4J: Fail ... 
- 滑雪                                                       分类:            POJ             2015-07-23 19:48    9人阅读    评论(0)    收藏
		滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ... 
- Power Strings                                                       分类:            POJ             串             2015-07-31 19:05    8人阅读    评论(0)    收藏
		Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ ... 
随机推荐
- (Command Pattern)命令模式
			定义 将“请求”封装成对象,以便使用不同的请求.队列或者日志来参数化其他对象.命令模式也支持可撤销的操作. 结构图: 命令模式的角色划分: Reciever(命令的接收者):接收命令,并知道如何进行必 ... 
- 将 IDENTITY 转换为数据类型 int 时出现算术溢出错误。
			IDENTITY标识列为int类型,取值范围为-2^32到2^31-1.当增长值超过这个最大值时,我在SQL Server 2008 R2 x64上试验的结果是: 将 IDENTITY 转换为数据类型 ... 
- 比较Date时间先后
			if ([firstDetailSelect compare:secondDetailSelect] == NSOrderedDescending) { [MBProgressHUD showErro ... 
- 转:Python获取随机数(英文)
			Random - Generate pseudo-random numbers Source code: Lib/random.py This module implements pseudo-ran ... 
- poj 题目分类(1)
			poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ... 
- the serializable class XXX does not declare a static final seriaVersionUID...的问题
			关于myeclips提示The serializable class XXX does not declare a static final serialVersionUID field of typ ... 
- 解决无法连接到visual studio开发服务器的问题
			今天vs抽风,调试网站出现下图那样: 然后我开始百度搜索 "无法连接到visual studio开发服务器" 出现很多文章: 打开一篇问题,看了里面的内容, 那个解决办法也不是最好 ... 
- cometd使用-bayeux协议(读法:贝叶)
			bayeux.createChannelIfAbsent("/**", new ServerChannel.Initializer() { @Override public voi ... 
- c++的学习内容一汇总篇(常更新)
			在这里假定读者们是有一定编程经验的.例如c#,java,c或者其他任何编程语言. 所有语言都无外乎掌握它的语法,熟悉它的一些库的调用. ---------------语法篇-------------- ... 
- 夺命雷公狗---DEDECMS----8dedecms干掉首页和-文档页-栏目页的页面的广告
			我们首先来将首页生成静态页面,如下图所示: 成功后,如下显示: 如果成功后则在文件夹下多了一个index.html的文件.. 我们的首页静态页面是通过模版文件生成,所以我们只需要把模版文件的广告标签删 ... 
