Insect Food Calculation

Source: Internet
Author: User

"Title description"

The so-called insect food calculation, is a part of the original formula has been chewed off by the worm, we need to determine the number of the remaining numbers to be chewed off the letter. Let's look at a simple example:

43#9865#045
+ 8468#6633
44445506978

the # number represents the number eaten by worms. According to the calculation, we can easily judge: the first row of two numbers are 5 and 3, the second row of the number is 5.
now, let's do two restrictions on the problem:
first of all, we only consider the addition of insect food calculation. The addition here is N-binary addition, the calculation of three numbers have n bits, allowing a leading 0.
Secondly, the worm eats up all the numbers, we only know which ones are the same, we use the same numbers in the same letters, different numbers are represented by different letters. If the equation is n-ary, we take the first n uppercase letters of the English alphabet to represent the n different numbers from 0 to N-1 in this equation: But the n-letters do not necessarily represent 0 to N-1 in sequence. Input data guarantees that n letters appear at least once.
BADC
+ CBDA
DCCC

the above equation is a 4-binary calculation. Obviously, we just have to let ABCD represent 0123, so we can make this equation. Your task is to find the number represented by n different letters for a given n-ary addition calculation, so that the addition formula is set up. The input data is guaranteed to have only one set of solutions,

"Input description"

The input contains 4 rows. The first line has a positive integer n (n <= 26), and the following 3 rows each have a string of uppercase letters representing two addend and A and. There are no spaces at either end of the 3 strings, from high to low, and there are exactly n bits.

"Output description"

The output contains one row. In this line, the unique set of solutions should be included. The solution is represented by: output n numbers, respectively, for A, B, C The number represented, the adjacent two digits are separated by a space and cannot have extra spaces.

"Sample Input"

5
abced
Bdace
Ebbaa

"Sample Output"

1 0 3) 4 2

"Data range and Tips"

For 30% of data, there is a guaranteed n <= 10;
For 50% of data, there is a guaranteed n <= 15;
For all data, it is guaranteed to have n <= 26.

Insect Food count

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.