Redian新闻
>
急问!编程实现数学运算相关面试题
avatar
急问!编程实现数学运算相关面试题# JobHunting - 待字闺中
S*C
1
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 ((((val1 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 60, 1, 3, 5, and
20. Bob rearranges the cards and supplies four operations, so that 5 * 20 -
60 + 3 - 1 = 42.
Input:
The input consists of five integers on a line, separated by spaces. Each
integer V is 0 <= V <= 52.
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.
avatar
S*C
2
用 Reverse_Polish_Notation实现可以简化答案
求大神提供更多思路!
avatar
n*n
3
这不就是24点的变种。

【在 S*******C 的大作中提到】
: 用 Reverse_Polish_Notation实现可以简化答案
: 求大神提供更多思路!

avatar
S*C
4
终于有大神出现,我没做过24点,能提供更多信息吗?
马上要面试了,感激不尽

【在 n******n 的大作中提到】
: 这不就是24点的变种。
avatar
S*C
5
找到了,本版终有大神

【在 n******n 的大作中提到】
: 这不就是24点的变种。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。