#include<stdio.h>
#include<math.h>
#include<string.h>
char s[250];
char a[10][250];
int a1[4];
int a2[250];
char ch; int init(int len)
{
int tt=0;
for(int i=1;i<=7;i++)
{
for(int j=0;j<(int)pow(2,i)-1;j++)
{
a[i][j]=s[tt++];
if(tt>=len)
break;
}
if(tt>=len)
break;
}
} int tran(int *aa,int len)
{
int temp=0;
for(int i=len-1,j=0; i>=0; i--,j++)
{
temp+=(int)aa[i]*pow(2,j);
}
return temp;
} int main()
{
while(gets(s)!=NULL)
{
memset(a,0,sizeof(a));
int len=strlen(s);
init(len); while(1)
{
int t2=0;
while(t2<3)
{
scanf("%c",&ch);
if(ch=='1'||ch=='0')
{
a1[t2]=ch-'0';
t2++;
}
}
int lenth=tran(a1,3);
if(lenth==0)
{
scanf("%c",&ch);
printf("\n");
break;
}
while(1)
{
int t3=0;
while(t3<lenth)
{
scanf("%c",&ch);
if(ch=='1'||ch=='0')
{
a2[t3]=ch-'0';
t3++;
}
}
int ans=tran(a2,lenth);
if(ans!=(int)pow(2,lenth)-1)
printf("%c",a[lenth][ans]);
else
break;
}
}
}
return 0;
}

uva 213 - Message Decoding (我认为我的方法要比书上少非常多代码,不保证好……)的更多相关文章

  1. UVa 213 Message Decoding(World Finals1991,串)

     Message Decoding  Some message encoding schemes require that an encoded message be sent in two part ...

  2. UVA 213 Message Decoding 【模拟】

    题目链接: https://cn.vjudge.net/problem/UVA-213 https://uva.onlinejudge.org/index.php?option=com_onlinej ...

  3. uva 213 Message Decoding

    思路来自紫书...开始时的思路估计100行+,果断放弃!关键:1.正确提取出函数!   initmap():初始化字母与整数的映射.   returnint(x):向后读取x位,并转换为十进制数返回. ...

  4. UVA - 213 Message Decoding (输入字符串并对单个字符进行操作的输入输出)

    POINT: 关于表示一个编码:利用code字符数组表示一个编码字符,其中code[len][val]表示长度为len,二进制值为val的字符: 主程序如下: #include <iostrea ...

  5. 【每日一题】 UVA - 213 Message Decoding 模拟解码+读入函数+阅读题

    题意:阅读理解难度一道比一道难orz.手摸了好久样例 题解: 读入:大循环用getline读入header顺便处理一下,  里面再写两重循环,外层一次读三个串,内层一次读num个串. 之后就查表,线性 ...

  6. uvaoj 213 - Message Decoding(二进制,输入技巧)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. Message Decoding UVA - 213

     Some message encoding schemes require that an encoded message be sent in two parts. The fifirst par ...

  8. 【例题 4-4 uva 213】Message Decoding

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 输入的二进制长度最长为7 所以得开个sta[7][2^7]的样子才存的下所有的字符的.. 定义这么一个数组当字典. 然后一个字符一个 ...

  9. UVa 213,World Finals 1991,信息解码

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

随机推荐

  1. Linux驱动之PCI

    <背景> PCI设备有许多地址配置的寄存器,初始化时这寄存器来配置设备的总线地址,配置好后CPU就可以访问该设备的各项资源了.(提炼:配置总线地址)   <配置寄存器>   ( ...

  2. 面向对象设计原则 迪米特法则(Law of Demeter)

    迪米特法则(Law of Demeter) 又叫作最少知识原则(Least Knowledge Principle 简写LKP),英文简写为: LoD. 这是一种面向对象程序设计的指导原则,它描述了一 ...

  3. CodeForces1070A Find a Number 图论

    令状态$f(i, j)$表示模$d$为$i$,和为$j$时的最小数 可以通过$bfs$来转移 然而就没了... 复杂度$O(10ds)$ #include <queue> #include ...

  4. 【漏洞预警】Apache ActiveMQ Fileserver远程代码执行漏洞(CVE-2016-3088)

    漏洞编码:CVE-2016-3088 实验环境:Linux Apache ActiveMQ版本号:Apache ActiveMQ 5.7.0 ----------------------------- ...

  5. bzoj 4176: Lucas的数论 -- 杜教筛,莫比乌斯反演

    4176: Lucas的数论 Time Limit: 30 Sec  Memory Limit: 256 MB Description 去年的Lucas非常喜欢数论题,但是一年以后的Lucas却不那么 ...

  6. Android 中点击返回键弹出“在按一次退出程序”的做法

    在很多应用中都有这种做法,连续点击两次才退出程序,目的是为了防止用户不小心点击到了返回键而退出程序了,添加了一次用户确认的过程. 其实做法很简单,只需要做一个延时的消息处理就可以了. 首先在我们在一个 ...

  7. 解决mysql控制台查询数据乱码的问题,有图有真相

    在mysql  控制台当 当为gbk的时候查询的数据是汉字,假设不是则为乱码.  set  names  gbk;  那么查询出来的数据则为汉字

  8. C 常量的类型

    http://bbs.csdn.net/topics/380028485 整型常量的类型是下列相应表中第一个能表示其值的类型: int --> long int --> long long ...

  9. ASP.NET Web API教程 分页查询

    首先增加支持分页的API方法 public IEnumerable<UserInfo> GetUserInfos(int pageindex, int size)         {    ...

  10. C#编程(一)

    第一个简单的C#程序 using System; using System.Collections.Generic; using System.Linq; using System.Text; usi ...