Message Decoding

UVA - 213

题目传送门

emmmm,此题按照紫书上的思路来即可,要么太复杂

AC代码:

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int readchar()
{for(;;) {int ch=getchar();if(ch!='\r'&&ch!='\n') return ch;}
}
int readint(int c)
{int v=0;while(c--) {v=v*2+readchar()-'0';}return v;
}
int code[8][1<<8];
int readcodes()
{ms(code);code[1][0]=readchar();for(int len=2;len<=7;len++) {for(int i=0;i<(1<<len)-1;i++) {int ch=getchar();if(ch==EOF) return 0;if(ch=='\n'||ch=='\r')return 1;code[len][i]=ch;}}return 1;
}
int main()
{#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);while(readcodes()){for(;;) {int len=readint(3);if(len==0)break;for(;;) {int v=readint(len);if(v==(1<<len)-1) break;putchar(code[len][v]);}}putchar('\n');}return 0;
}

UVA - 213 Message Decoding相关推荐

  1. UVA 213 Message Decoding

    题目链接:https://vjudge.net/problem/UVA-213 题目翻译摘自<算法禁赛入门经典> 题目大意 考虑下面的 01 串序列: 0, 00, 01, 10, 000 ...

  2. UVA 213 - Message Decoding 简单题 lambda表达式 23333333

    不知道算什么类型才好.......就是按照题意描述读就行了 从来没有写过3个while循环叠在一起...... 至于根据号码去找在header里面的下标,其实就是一个二元函数(length,value ...

  3. UVA213 UVALive5152 Message Decoding

    World Finals >> 1991 - San Antonio 问题链接:UVA213 UVALive5152 Message Decoding. 问题简述:参见问题链接. 问题分析 ...

  4. 《算法竞赛入门经典》 例题 4-4 信息编码 (Message Decoding,ACM,ICPC World Finals 1991,UVa 213)

    原题及翻译 Some message encoding schemes require that an encoded message be sent in two parts. 某些消息编码方案要求 ...

  5. UVa213 - Message Decoding

    题意:给出一个字符串及其编码序列,解码得到原始序列.编码序列是用的二进制.形式如0,00,01,10.也就是根据二进制的位数及其所能表示的二进制,注意全1的不包含在内.0对应字符串的第一个字符,00对 ...

  6. 信息解码(Message Decoding)ACM题目

    分析: 长度为1的串,可以放1个编码 长度为2的串,可以放3个编码 长度为3的串,可以放7个编码 ..... 长度为n的串,可以放 n^2 -1 个编码 思路: 1. 用 1<<n  表示 ...

  7. 算法竞赛入门经典(第二版) | 例题4-4 信息解码 (紫皮书牛啤!)(UVa213,Message Decoding)

    大意: 二进制编码中取前三位,得到编码长度为n(0<=n<=7), 按此长度重复截取编码中剩余部分(n位一截),直到读取n个1结束.再次取三位,长度为n,重复上述操作-直至n个1后接000 ...

  8. Message Decoding密码翻译

    这是一道模拟题ex 其实每一道模拟题都很"简单", 这道题就是难在读英文题!处理输入! 真的我竟然花了几个小时就只是为了看懂样例!!orz 题目大意 考虑下面的01串序列: 0,0 ...

  9. java长度为100的数组_产生一个int数组,长度为100,并向其中随机插入1-100,不重复...

    #define RANDOM(X) (rand() % X + 1) int main() { //标志数组 int book[] = {}; int result[] = {}; //默认的随机数种 ...

最新文章

  1. MCU小tips(提高效率)
  2. out和ref之间的区别
  3. Andrew Ng机器学习(二):逻辑回归
  4. Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR)
  5. linux怎么调整运行模式,如何手动设置修改X-Window的显示模式-linux思想
  6. Canvas绘制图形图像
  7. 神策数据:围绕跨境电商“人货场”,数据如何助力品牌乘风出海?
  8. 一、数据预处理——数据归一化 数据标准化
  9. android 跳转动画黑屏,Android8.0 适配解决页面跳转过程出现短暂黑屏的问题
  10. 【OpenCV 例程200篇】46. 直方图均衡化
  11. Modbus寄存器地址规则
  12. 为什么有的人有心事就容易失眠?
  13. 三极管特性——截止区、放大区、饱和区
  14. catia 桥接曲面圆角_CATIA建模教程_二_圆角及桥接在空间曲线中的应用
  15. 小故事分解区块链--科普篇
  16. matlab历史模拟法计算var,历史模拟法、蒙特卡罗模拟法计算VaR和ES值
  17. vivox27怎么去掉信息红点_还记得五彩斑斓的黑?vivo X27 Pro获红点奖
  18. 迈向“5G智慧校园”的第一步,启用人脸识别门禁设备
  19. 前端框架学习-layui
  20. 机械硬盘4k读写速度_极速鲨课堂43:机械硬盘秒变固态靠谱吗?

热门文章

  1. C语言 数组排序 – 选择法排序 - C语言零基础入门教程
  2. Python 线程队列 LifoQueue – LIFO - Python零基础入门教程
  3. Python 字符串/列表/元组/字典之间的相互转换 - Python零基础入门教程
  4. ajax中res和req,javascript – 来自AJAX调用的res.redirect
  5. JAVA如何隐藏异常堆栈_java – 如何在控制台上停止打印异常堆栈跟踪?
  6. 用栈实现计算器c语言报告,请问,用c语言做一个计算器 包括+-*/()的运算 用栈 该怎么做...
  7. python导入pillow模块_Python:argparse模块和pillow-image
  8. python中怎么创建配置文件_如何在Django中创建配置文件注册表单?
  9. python异步框架twisted_Python学习八十七天:使用异步的twisted框架写入数据
  10. windows php sqlite,如何在Apache 2.4(Windows 7)上为PHP 5.6.14配置SQLite3?