Ultraviolet A 10878-decode the tape

Source: Internet
Author: User

Your boss has just uneared 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 Sample output
___________| 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 |___________
A quick brown fox jumps over the lazy dog.

Problemsetter: Igor naverniouk

Special thanks: BSD games PPT.

[Resolution ]:

The input can be viewed as a piece of tape from the top down.
The question provides very little information, so most of the information should be obtained from the input and output.
(It is equivalent to giving you a plaintext text and a password, and then you can crack the encryption rules)

First, we found that there are 43 lines of tape, the same as the number of characters in the password (including line breaks ).
You can guess whether a line of tape represents a single character.
Then we can find that the same characters in the password are the same as the corresponding lines in the tape.
Our speculation is even stronger.

Then we observe the structure of each line in the tape.
The overall format is the same. Only "O" has different positions and quantities.
In addition, "O" will only appear at 7 fixed positions.
Then there are 7 locations, which can represent 2 ^ 7 = 128 characters in total.
Integer feature (ASCII Code) of the contact character ),
It can be guessed that each line of the tape represents a binary number, which is exactly the ASCII code of the corresponding character.

Take a look at the corresponding line "O." of the space (ASCII code 32 .",
Consider the space in the row as 0, and the "O" as 1. Then we can get the binary number of 0100000, Which is exactly 32.
Deciphering is complete.

[Code ]:

/********************************** Date: * Author: sjf0115 * question: 10878-decode the tape * Source: http://uva.onlinejudge.org/index.php? Option = com_onlinejudge & Itemid = 8 & category = 20 & page = show_problem & problem = 1819 * result: AC * Source: VA * conclusion: * *********************************/# include <stdio. h> # include <string. h> int C [] = {0, 0, 64, 32, 16, 8, 0, 4, 2, 1, 0}; int main () {char STR [15]; int value, I; // freopen ("C: \ Users \ xiaosi \ Desktop \ acm.txt", "r", stdin ); gets (STR); While (gets (STR) & STR [0]! = '_') {Value = 0; int Len = strlen (STR); for (I = 2; I <Len; I ++) {If (STR [I] = 'O') {value + = C [I] ;}} printf ("% C", value );}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.