UVA213----Message Decoding
来源:互联网 发布:运动数据记录器 编辑:程序博客网 时间:2024/06/05 15:16
由于字符比较少,只有7个,再将每个二进制转换成数值的形式,存到数组的位置。
如样例2 解码key为"S#**\"
code[1][0]对应编码'0'存的字符为'$' code[2][0]对应编码'00'存的字符为'#'
code[2][1]对应编码'01'存的字符为'*' code[2][2]对应编码'10'存的字符为'*'
code[3][0]对应编码'000'存的字符为'\'
第一个位置放长度,第二个放对应编码。
#include<stdio.h>#include<algorithm>#include<cmath>#include<string.h>using namespace std;int readchar(){ for(;;){ int ch=getchar(); if(ch!='\n'&&ch!='\r') return ch; }}int readint(int c)//长度为c{ int v=0; while(c--) { v=v*2+readchar()-'0'; } return v;//转换为数值}int code[8][1<<8];int readcodes(){ memset(code ,0,sizeof 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(){ while(readcodes()){ for(;;){ int len=readint(3); if(len==0) break;//对应000 for(;;){ int v=readint(len); if(v==(1<<len)-1) break;//对应几个1 putchar(code[len][v]); } } putchar('\n'); } return 0;}
0 0
- UVA213 - Message Decoding
- UVa213 Message Decoding
- UVa213 - Message Decoding
- UVA213----Message Decoding
- UVA213 UVALive5152 Message Decoding
- UVa213-Message Decoding
- UVa213 Message Decoding
- UVa213 Message Decoding
- UVA213 Message Decoding(二进制)
- 水题:UVa213- Message Decoding
- 算法竞赛入门经典 UVa213 Message Decoding
- Message Decoding
- Message Decoding
- 算法竞赛入门经典(第二版) 例题4-4 信息编码(Message Decoding) UVa213 Finals1991 (二进制)
- uva -213Message Decoding
- UVa 213 - Message Decoding
- UVaOJ-213 Message Decoding
- UVA【213】 Message Decoding
- 给小白的Java EE生存指南(5) :AJAX
- 中介者模式
- cf602e New Year Tree dfs序+二进制+线段树区间修改
- 从IAR arm 5.5 IAR ARM 6.30 等低版本升级为高版本 IAR arm 7.4
- Spring MVC 中文件上传
- UVA213----Message Decoding
- SpringMVC+Mybatis框架整合源码SSM Nginx,Hudson
- CodeForces 599D Spongebob and Squares(DP+math)
- gcc编译参数-fPIC的一些问题
- UI组件之Spinner
- 231,NSOperation和NSOperationQueue
- 感觉自己好弱
- ZOJ 1049 题目大意就是路易斯安那每年缩减50 square miles,缩减的是以(0,0)为圆心的半圆,对于任意x,y坐标,输出几年之后被淹没
- 2016蓝桥杯假期任务之《切面条》