NUMBERS and letters P49602


Statement
 

pdf   zip

thehtml

Welcome, contestant. ¿Do you like numbers? Because in the today test you must solve the famous game of the numbers, of the well known game show “Numbers and Letters”. (Yes, really, it is a well known game show; if you do not know it, it is your fault. It was broadcasted in the 90s in La 2, and it is still broadcasted in some autonomic televisions; the original French game show, “Des chiffres et des lettres”, is being broadcasted since 1972).

The game of Numbers consist of: you must use six numbers obtained at random to form a three-figure objective number, only using the 4 arithmetic operations (addition, subtraction, multiplication and division) with any of the six first numbers, in any order. It is only allowed to divide two numbers if the division is exact and, obviously, the divisor is not 0.

For instance: if the numbers were

8   2   50   100   3   5 

and the objective number was the 195, we would answer that the game has solution, because 100+50=150, 150*8 = 1200, 1200/3 = 400, 400/2 = 200, 200−5=195.

Another instance: if the numbers were

8   2   6   75   3   5 

we could also solve the same objective number 195, because 75+8=83, 6*3=18, 83−18=65, 5−2=3, 65*3=195.

Instead, if the numbers were

2   100   6   75   2   2 

and the objective number was the 809, we would have to accept the defeat, because it not possible to combine that 6 numbers to form the 809. However, to say another instance, it is possible to form the 980 using, in fact, only 5 numbers of the numbers: 100−2 = 98, 6+2 = 8, 8+2=10, 98*10=980.

Input

The input consists of exactly 7 numbers separated by spaces, that describe a problem of Numbers. The first number is the objective number, a natural between 100 and 999; the six other numbers are the base numbers, that are natural numbers that belong to the set {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 25, 50, 75, 100}.

Your program must solve 5 inputs in less than a second.

Output Your program must print in a line “Le Compte est bon” if it is possible to form the objective number doing arithmetic operations in some of the six base numbers, or “C’est pas possible” if there is not any solution.

Public test cases
  • Input

    195 8 2 50 100 3 5
    

    Output

    Le Compte est bon
    
  • Input

    195 8 2 6 75 3 5

    Output

    Le Compte est bon
    
  • Input

    809 2 100 6 75 2 2
    

    Output

    C'est pas possible
    
  • Input

    980 2 100 6 75 2 2

    Output

    Le Compte est bon
    
  • Information
    Author
    Omer Giménez
    Language
    English
    Translator
    Carlos Molina
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++