HNU Number Guessing

Source: Internet
Author: User

HNU Number Guessing

 

Description

Number Guessing is a computer game. first, the computer chooses four different digits, you need to guess these four digits in the fewest times, for each guess, the computer will show a judgement in the form of "# A # B", "#" is a number 0 ~ 4. "# A" shows how should digits you guessed with both correct value and position. "# B" shows how should digits you guessed with correct value. for example, the computer chose 1234, and you guessed 6139, the computer will show "1A2B" for you have number "1" correct value but wrong position and number "3" correct value with correct position. thus the computer gives you the judgement of "1A2B ". now you hav E memorized the digits you guessed and the judgements you got, you feel like you can figure out the correct answer. Life is filled with wisdom, isn' t it?

Input

There are several test cases. for each test case, the first line contains a single positive integer N indicates the times you can guess, the following N lines is the record of the guess, in the form:

##### A # B

The first four numbers is the numbers guessed, then the judgements for your guess. The input is terminated by a negative integer.

Output

For each test case, output a single line contains exactly four digits that the computer has chosen. You may assume that each test case gives you enough information, so you can figure out the correct answer.

Sample Input

21234 2A4B1243 0A4B30732 3A3B1526 0A0B4567 0A2B-1

Sample output

21340734

 

 

#include 
 
  #include 
  
   #include 
   
    #include 
    
     #include 
     
      #define N 19using namespace std;int s[N],aa[N],bb[N],a[N];int n;int check(int ans){    for(int k=0;k
      
       

 

 

 

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.