【ACM】Solution of UVA 213-Message Decoding
来源:互联网 发布:怎么分析数据 编辑:程序博客网 时间:2024/06/05 19:36
这题TLE了无数次,终于在学长的帮助下改出来了 太开心了 因为太开心了所以把字体颜色改成了AC色hhhhhhha
先膜一发LRJ老师。。。这题按紫书上的写法处理真的挺容易的
本题总结:
1、本题的读入要特别注意处理回车
2、我采用的是二维数组,范围是[8][(1<<7)]但是预防万一我开大了点。也可以压成一维的
3、循环判断条件中尽量不要出现需要计算的。就是因为这个TLE的
#include<stdio.h>#include<string.h>char header[10][500]={{0}};int read_header(){ char c = getchar(); while (c == '\n' || c == '\r') c = getchar(); if (c == EOF) return 0; else { header[1][0] = c; return 1; }}int get_int (int len){ int t = len, tot = 0; while (t) { char c = getchar(); if (c != '\n' && c != '\r') { t--; tot += (c-48)<<t; } } return(tot);}int main(){ char c; while (read_header()) { for (int i = 2; ; i++) { int x = (1<<i)-1; //而不是在循环变量处写j<(1<<i)-1 for (int j = 0; j < x; j++) { c = getchar(); if (c == '\n' || c == '\r') break; header[i][j] = c; } if (c == '\n' || c == '\r') break; } while (1) { int len = get_int(3); if (len == 0) break; int all_one = (1<<len)-1; while (1) { int num = get_int(len); if (num == all_one) break; putchar(header[len][num]); } } printf("\n"); memset(header,0,sizeof(header)); } return 0;}
0 0
- 【ACM】Solution of UVA 213-Message Decoding
- uva -213Message Decoding
- UVa 213 - Message Decoding
- UVA【213】 Message Decoding
- uva 213 Message Decoding
- UVA-213-Message Decoding
- UVa-213Message Decoding
- UVA - 213 Message Decoding
- Uva - 213 - Message Decoding
- UVA - 213 Message Decoding
- UVA 213 Message Decoding
- UVa 213 Message Decoding
- uva 213 Message Decoding
- UVa 213 Message Decoding
- UVA 213 Message Decoding
- Message Decoding UVa 213
- Uva 213 Message Decoding
- UVa 213 - Message Decoding
- 学习Spring Cloud第五课(Eureka简介与Eureka Server示例)
- POJ - 1797 Heavy Transportation
- 歌曲光辉岁月和弦走向探究
- 【LeetCode】513. Find Bottom Left Tree Value【M】【73】
- Java中的ReentrantLock和synchronized两种锁定机制的对比
- 【ACM】Solution of UVA 213-Message Decoding
- Rxjava_自己实现Rxjava map转换及源码分析
- Java中的位运算
- cf105 E. Porcelain 背包dp
- AngularJS开发指南14:依赖注入
- 数据库触发器简单解析
- Windows下echo内容包括>的解决办法
- unity 優化總結
- View的工作原理(二)----View的工作流程