UVa 10344:23 out of 5, intellectual games: 23 points

Source: Internet
Author: User
Tags arithmetic

Topic Link:

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=108&page=show_ problem&problem=1285

Type: Backtracking

Original title:

Your task is to write a program so can decide whether can find a arithmetic expression consisting of five given Num Bers

(1<=i<=5) That would yield the value 23. For this problem we'll only consider arithmetic expressions of the following from:

: {1,2,3,4,5}-> {1,2,3,4,5} is a bijective function

 {+,-,*} (1<=i<=4)

Sample input:

1 1 1 1 1
1 2 3 4 5
2 3 5 7 11
0 0 0 0 0

Sample output:

Impossible
Possible
Possible
The main effect of the topic:
The question is better, the rules of the game and playing cards "count 24 points" basically the same.
The rule is this: give you 5 cards, and then ask you to use +,-, * These three symbols, to calculate these 5 numbers, so that their sum is 23.
You have to program to determine whether all 5 cards can achieve 23 points.
Ideas and Summary:
This game believes that many people have played in childhood, if a child can be a small program to help us, then. It's going to be programmed or something.
At least you can cheat children ...
If you use the computer to do with the recursive backtracking algorithm, then it will be very simple thing, only need to violently search out all the permutations, with all the symbols,
You can easily get the answer

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.