您的位置:首页 > 其它

UVA 10878-Decode the tape(模拟)

2014-12-26 00:45 357 查看
Decode the tape
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld
& %llu
Submit Status

Description

"Machines take me by surprise with great frequency."
Alan Turing

Your boss has just unearthed a roll of old computer tapes. The tapes have holes in them and might contain some sort of useful information. It falls to you to figure out what is written on them.

Input

The input will contain one tape.

Output

Output the message that is written on the tape.

Sample Input

___________
| o   .  o|
|  o  .   |
| ooo .  o|
| ooo .o o|
| oo o.  o|
| oo  . oo|
| oo o. oo|
|  o  .   |
| oo  . o |
| ooo . o |
| oo o.ooo|
| ooo .ooo|
| oo o.oo |
|  o  .   |
| oo  .oo |
| oo o.ooo|
| oooo.   |
|  o  .   |
| oo o. o |
| ooo .o o|
| oo o.o o|
| ooo .   |
| ooo . oo|
|  o  .   |
| oo o.ooo|
| ooo .oo |
| oo  .o o|
| ooo . o |
|  o  .   |
| ooo .o  |
| oo o.   |
| oo  .o o|
|  o  .   |
| oo o.o  |
| oo  .  o|
| oooo. o |
| oooo.  o|
|  o  .   |
| oo  .o  |
| oo o.ooo|
| oo  .ooo|
|  o o.oo |
|    o. o |
___________


Sample Output

A quick brown fox jumps over the lazy dog.


考察二进制编码。把o看成1,把‘ ’(空格)看成0,其余的不需要管,但是记住第二个|要输出当前的字符。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
char str;
int cnt=0;
int sum=0;
while((str=getchar())!=EOF)
{
if(str=='o')
sum=sum*2+1;
else if(str==' ')
sum=sum*2;
else if(str=='|')
{
cnt++;
if(cnt==2)
{
putchar(sum);
cnt=0;
sum=0;
}
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: