Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Alice has invented a new card game to play with Bob. Alice made a deck of cards with random values between 1 and 52.

Alice has invented a new card game to play with Bob. Alice made a deck of cards with random values between 1 and 52. Bob picks 5 cards. Then, he has to rearrange the cards so that by utilizing the operations plus, minus, or times, the value of the cards reach Alice's favorite number, 42. More precisely, find operations such that ((vall op1 val2) op2 val3) op3 val4) op4 val5) = 42. Help Bob by writing a program to determine whether it is possible to reach 42 given 5 card values. For example, Bob picks 5 cards out of the deck containing 40, 1. 3, 4, and 20. Bob rearranges the cards and supplies four operations, so that 4 * 20 - 40 + 3 -1 = 42. Input: The input consists of five integers on a line, separated by spaces. Each integer is between 1 and 52, inclusive. Output: Print a line containing "YES" if it is possible to reach the value 42 according to the rules of the game, or "NO" otherwise. Test 1 Test Input D 40 1 3 4 20 Expected Output B YES

Step by Step Solution

3.37 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

Code include using namespace std typedef long long ll int ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Statistics Data Analysis And Decision Modeling

Authors: James R. Evans

5th Edition

132744287, 978-0132744287

More Books

Students also viewed these Mathematics questions