403542: GYM101192 D Bulls and cows

Memory Limit:64 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Bulls and cowstime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

You woke up on the chilly tiled floor of a farm. "Hello…", said a spooky voice. "I want to play a game." You did not have a choice, so you listened to the game’s rules.

The voice knows a 4-digit secret number, all digits of which are different. You need to guess it and for that you can make several tries. During each try you say a 4-digit number, all digits of which are different. The voice tells you the number of matches. If the matching digits are in their right positions, they are called "bulls"; if in different positions, they are "cows".

For example: the secret number is 3219. Your try is 2310 and the voice’s answer is 12: one bull (the digit 1 is on the right position) and two cows (digits 2 and 3 are present in the number, but they are in different positions).

You have at most 8 tries to guess the secret number. Once you guess it, you can leave the crazy farmer’s place alive. Good luck!

Input

For each your try you will receive a line of two digits: number of bulls and number of cows.

Output

Don’t forget to put a newline character and to flush the output stream after you print your guess. For example fflush(stdout) in C++, System.out.flush() in Java, and flush(output) in Pascal.

ExampleInput
0123
0145
0256
0612
0178
0619
Output
11
11
11
30
11
40

加入题单

算法标签: