| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 455 人关注过本帖
标题:Candy box
只看楼主 加入收藏
欣飞飞
Rank: 1
等 级:新手上路
帖 子:20
专家分:1
注 册:2013-10-6
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
Candy box
Description :
Princess Biving has a lot of candies ,and this day she wants to eat some of them .
Formally speaking ,Biving has N candy boxes ,and the ith box contains Ci candies .she wants to open no more than K of N boxes and the sum of candies of these K boxes is exactly M ,tell Biving whether she can accomplish this idea.

Input specification:
The input contains multiple test cases (<=100).
The first line of each test case contains two integer N,Q(1<=N<=100,1<=Q<=1000)which mean the number of candy boxes and queries Next line contains N integer C!,C2,....,CN(1<=Ci<=100).Then comes Q lines ,each line has two integers Ki and Mi(1<=ki<=N,1<=Mi<10000).


output specification:
For each case ,first output "Case #c:",then for each query output "Yes"in a single line if Biving can accomplish her idea ,otherwise output "No".


Sample input:
4 2
1 2 2 4
1 3
2 3
4 1
1 2 4 8
3 7


Sample output:
Case #1:
No
Yes
Case #2:
Yes


这题怎么做啊?不知道怎么挑几个数相加
搜索更多相关主题的帖子: speaking multiple exactly whether candy 
2013-11-10 19:39
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:14 
你懒得翻译一下,别人也肯定懒得回答
2013-11-11 09:04
快速回复:Candy box
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018161 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved