Decode the tape
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %ll
Description
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.
坑题,本题后台不知有多少数据,反正二维数组我没能开出那么大的内存来直接装下它,只能每次输入一行,然后转换成字符再输出,即使是这样,一维数组开到10000都没对,只好开到100000,才AC。。。。。
#include <stdio.h>
#include <string.h>
char mp[1000010];
int s[1000010];
int zh(int x)
{
int sum = 0,y = 0;
for(int i = x - 1;i >= 0;i--)
{
sum += (s[i] * (1 << y));
y++;
}
return sum;
}
int main()
{
int x;
while(gets(mp))
{
int m = strlen(mp);
x = 0;
for(int i = 0;i < m;i++)
{
if(mp[i] == ' ')
s[x++] = 0;
else if(mp[i] == 'o')
s[x++] = 1;
}
if(x != 0)
printf("%c",zh(x));
}
return 0;
}