2015 APAC test__ Mess

Source: Internet
Author: User

Problem A. Seven-segment Display
This contest are open for practice. You can try every problem as many, though we won ' t keep track of which problems for you. Read the Quick-start Guide to get started.
Small input
8 points
Solve A-small
Large input
Points
Solve A-large
Problem

Tom is a boy whose dream was to become a scientist, he invented a lot in his spare time. He came up and a great idea several days ago:to make a stopwatch by himself! So he bought a seven-segment display immediately.

The seven elements of the display are all light-emitting diodes (LEDs) and can is lit in different to combinations NT The Arabic numerals like:

However, just when he finished the programs and tried to test the stopwatch, some of the LEDs Some of the segments can never is lit while others worked fine. So, the display kept on producing some ambiguous states "all" time ...

Tom has recorded a continuous sequence of States which were produced by the display and are curious about whether it is POS Sible to understand what this display is doing. He thinks the "the" to determine the "state which" the display would show next, could for help him?

Please note this display works despite those broken segments which means the display would keep on counting Down cyclically starting from a certain number (can is any one of the 0-9 since we don ' t know where this record start s from). ' cyclically ' here means the display reaches 0, it'll keep on counting down starting from 9 again.

For convenience, we refer the seven segments of the ' Display by the ' letters A to G as the ' picture below:

For example, if the record of States are like:

It ' s not so hard to figure out this only segment B is broken and the sequence of states the "display is" trying to produce is simply "9-> 8-> 7-> 6-> 5". Then the next number should is 4, but considering of the brokenness of segment B, the next state should to: Input

The "the" of the input gives the number of test cases, T. Each test case was a line containing an integer N which is the number of States Tom recorded and a list of the nstates separated by spaces. The ' is encoded into a 7-character string represent the display of segment a-g. Characters in the string can either to be ' 1 ' or ' 0 ', denoting the corresponding segment was on or off, respectively. Output

For each test case, output one line containing ' case #x: Y ', where x is the ' Test Case Number ' (starting from 1). If the input unambiguously determines the next state of the display, Y should is that next state (in the same format as th e input). Otherwise, y should be "error!". Limits

1 ≤ T ≤2000.
Small DataSet

1 ≤ N ≤5.
Large DataSet

1 ≤ N ≤100.
Sample


Input
4
1 1111111
2 0000000 0001010
3 0100000 0000111 0000011
5 1011011 1011111 1010000 1011111 1011011

Output
Case #1:1110000 case
#2: error!
Case #3:0100011 case
#4:0010011

Problem B. Super 2048 This contest are open for practice. You can try every problem as many, though we won ' t keep track of which problems for you. Read the Quick-start Guide to get started.

Small input
6 points
Solve B-small
Large input
Points
Solve B-large
Problem

2048 is a famous Single-player game in which the objective are to slide tiles on a grid to combine them and create a tile W ITH the number 2048.

2048 is played on a simple 4 x 4 grid with tiles This slide smoothly when a player moves them. For each movement, the player can choose to move all tiles in 4 directions, left, right, up, and down, as far as possible At the same time. If two tiles of the same number collide while moving, they would merge into a tile with the total value of the two tiles th At collided. in one movement, one newly created tile can do merged again and always are merged with the tile next to it along th e Moving direction. e.g. if the three "2" are in a row "2 2 2" and the player choose to move left, it would become "4 2 0", the most left 2 "2" are merged.

The above figure shows 4 x 4 grid varies when player moves all tiles ' right '.

Alice and Bob accidentally find this game and love the feel when two tiles are.  After a few round, they start to is bored about the size of the board and decide to extend the size of board to N X N, which they called the game "Super 2048".

The big board then makes them dazzled (no Zuo no Die-_-|). They ask for a program to write a and them figure out what the board'll be looked like after all tiles move to one SPE Cific direction on a given board. Input

The "the" of the input gives the number of test cases, T. T test Cases follow.  The ' the ' of each test case gives the side length of the board, N, and the direction the tiles would move to, DIRN and DIR are separated by a. DIR would be one of the four strings: "Left", ' right ', ' up ', or ' down '.

The next n lines each contain n space-separated integers describing the original state of the board. Each line represents a row of the board (from top to bottom); Each integer represents the value of a tile (or 0 if there isn't number at that position). Output

For each test case, output one line containing ' case #x: ', where x is the ' Test Case Number ' (starting from 1). Then output n more lines, each containing n space-separated integers which describe the Move in the same format as the input. Limits Each number in the "grid is either 0 or a" two between 2 and 1024, inclusive. Small DataSet

1 ≤ T ≤20
1 ≤ N ≤4
Large DataSet

1 ≤ T ≤100
1 ≤ N ≤20
Sample


Input

Output
3
4 Right
2 0 2 4 2 0 4 2 2 2 4 8 2 2 4 4
ten up
2
0 0 0 0 0 0 0 0 0 2 0 0 0 0 the 0 0 0
     2, 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0-0 0 0 0 2-0-0-0-the-0-0-0-0 0 0 2 0 0 0 0 0 0
0
     2 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 right
0
3 2 2 2 4 4 4 8

Case #1:0 0 4 4 0 2 4 2 0 4 4 8 0 0 4 8 case
#2:
4
0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0-
4 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0-----the------the---0 0 0 4 0 0 0 0 0 0 0 0 0, 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 case
#3:
0 0
0 2 4 0 8 16


Problem C. Addition This contest are open for practice. You can try every problem as many, though we won ' t keep track of which problems for you. Read the Quick-start Guide to get started.

Small input
One points
Solve C-small
Large input
Points
Solve C-large
Problem

Six years ago, a robot, Bob, with infant ' s intelligence-has been-invented by a evil, Alice.

Now the robot are six years old and studies in primary school. Addition is the the-operation he learned in math. Due to his strong reasoning ability, he could now conclude a+b=12 from a=2 and b=10.

Alice wanted to test Bob ' s addition skills. Some equations were given to Bob into form of a=2, b=10, c=4, and Bob has to find out the answers of questions like A+b, a+c , etc.

Alice checked Bob ' s answers one by one in the test papers, and no mistake has been the found of so far, but Alice lost the given Equations after a cup of the coffee poured on them. However She has some of Bob's correct answers, e.g a+b=12, a+c=6, c+d=5. She wants to continue with the checkable equations, e.g. B+D=11 could is concluded by a+b=12, A+c=6, c+d=5, and thus the Q Uestion B+d is checkable.

To prevent the artificial intelligence technology from being under the control of Alice, for you disguised yourself as her Istant. Now Alice wants/figure out which of the rest of questions are checkable and their answers. Input

The "the" of the input gives the number of test cases, T. T test Cases follow.

The ' the ' of each test case contains a single integer N: The number of correctly answered questions. Each of the next N lines contain one correctly answered question in the form "x+y=z", where x and y are names of variables and z is a decimal integer.

The next line contains a single integer Q: The number of remaining questions. Each of the next Q lines contain one question the form "x+y", where x and C15>y are names of variables. Output

For the all test case, the ' the ' of Output contains ' case #x: ', where x is the ' test Case number (start ing from 1). For each question in the is checkable, output a single line with the answer in the form "x+y =Z, where x and y are names of variables andz is a decimal integer. Questions should is listed in the same order as they were the input. Please don't ignore duplicated questions, since Alice would fire if you are pointed any mistake of hers. Limits

Names of variables are strings of lowercase Chinese 中文版 letters. Each name contains at most characters.

-200000≤ z ≤200000

There is no contradiction in the answered questions. Small DataSet

T ≤10

N ≤10

Q ≤10 Large DataSet

T ≤3

N ≤5000

Q ≤5000 Sample


Input

Output
2
2
apple+banana=10
coconut+coconut=12
5
apple+banana
apple+banana
apple+apple
banana+apple
peach+apple
3
a+b=3
b+c=3
c+d=3
4
a+c
a+d b+c
B+d

Case #1:
apple+banana=10
apple+banana=10
banana+apple=10 case
#2:
a+d=3
b+c=3

Problem D. Cut Tiles This contest are open for practice. You can try every problem as many, though we won ' t keep track of which problems for you. Read the Quick-start Guide to get started.

Small input
Points
Solve D-small
Large input
Points
Solve D-large
Problem

The

Enzo is doing renovation to his new house. The most difficult part are to buy exactly the right number of tiles. He wants  N  tiles of different sizes. Of course they have to being cut from the tiles he bought. All the required tiles are square. The lengths of side of the tiles are  2s1 ,   2S2 , ...,   2SN . He can only buy a lot of tiles sized  m * M , and him decides to only cut tiles parallel To their sides for convenience. How many tiles does him need to buy?

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.