码迷,mamicode.com
首页 > 其他好文 > 详细

ACM 原来这么有趣

时间:2015-05-10 11:23:37      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

我在过去24小时里,一直被这题折腾着。。。

 

题目: 

A Math game
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 256000/128000KB (Java/Others)

Problem Description

Recently, Losanto find an interesting Math game. The rule is simple: Tell you a number H, and you can choose some numbers from a set {a[1],a[2],......,a[n]}.If the sum of the number you choose is H, then you win. Losanto just want to know whether he can win the game.
Input

There are several cases.
In each case, there are two numbers in the first line n (the size of the set) and H. The second line has n numbers {a[1],a[2],......,a[n]}.0<n<=40, 0<=H<10^9, 0<=a[i]<10^9,All the numbers are integers.
Output

If Losanto could win the game, output "Yes" in a line. Else output "No" in a line.

Sample Input
10 87
2 3 4 5 7 9 10 11 12 13
10 38
2 3 4 5 7 9 10 11 12 13

Sample Output
No
Yes

简述之就是子集和问题。

 

ACM 原来这么有趣

标签:

原文地址:http://www.cnblogs.com/lv88/p/4491796.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!