2 shunfurh shunfurh 于 2017.09.09 23:43 提问

Cutting Banknotes

Philip is often faced with a big problem: after going out for dinner or having a few beers, he owes money to his friends or the other way around. These are often small amounts, but because Philip hates coins, his wallet contains only banknotes. Therefore he usually can't pay the amount exactly. Since he hates coins, he also doesn��t allow his friends to return them as change. He does allow for banknotes as change though.

To accomodate for this problem, he and his friends came up with the following idea: let's pay with pieces of banknotes. To make the cutting easy, they only cut banknotes in two equally-sized pieces, cut those pieces in two pieces, and so on. This yields a much larger range of amounts that can be paid. Philip wonders which ones exactly.

Input

On the first line an integer t (1 <= t <= 100): the number of test cases. Then for each test case:

One line with a number x (0.01 <= x <= 10 000.00): the amount Philip has to pay.

This is formatted with two decimal digits and a period as decimal separator.

One line with a positive integer n (1 <= n <= 1 000): the number of different banknotes.

n lines, each with an integer bi (1 <= bi <= 10 000): the values of the banknotes.

Output

For each test case:

One line with "yes" if the amount can be paid exactly and "no" otherwise.

Sample Input

4
10.75
3
2
10
20
0.33
1
1
10000.00
1
2500
1.00
2
3
5

Sample Output

yes
no
yes
yes

1个回答

devmiao
devmiao   Ds   Rxr 2017.09.27 21:51
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Doug Cutting (Lucene-Nutch-Hadoop 创始人简介)
吃水不忘挖井人,介绍Doug Cutting大牛是十分有必要的。      最早,接触到搜索引擎,知道有个Nutch(开源搜索引擎),于是开始查看Nutch相关的资料,发现了Nutch的创始人Doug Cutting,随着项目的深入,发现Doug Cutting本人不仅是Nutch的创始人,还是Lucene(开源的全文检索包)项目的创始人,之后Doug Cutting加入Yahoo,06年成
Codeforces 963C. Cutting Rectangle
感谢lxy教会我这题qaq w和h具体是什么不重要,先将他们离散化,然后把c[i]记成c[w][h]的形式 如果有某个c[w][h]=0一定不合法,并且c[w][1]:c[w][2]:....c[w][h]c[w][1]:c[w][2]:....c[w][h]c[w][1]:c[w][2]:....c[w][h]这个比例对所有w相同,这样才存在合法方案 单独考虑一种方块c[w][h],可...
FZU2268 Cutting Game(数学,规律)(第七届福建省大学生程序设计竞赛)
题目: Problem 2268 Cutting Game Accept: 10    Submit: 12 Time Limit: 1000 mSec    Memory Limit : 32768 KB  Problem Description Fat brother and Maze are playing a kind of special (hentai
2.1 Localization and Cutting-Plane Methods
Locatization and Cutting cutting-plane oracle 切平面池 finding cutting-planes 找到切平面 localization algorithms 定位算法 specific cutting -plance methods 特定切平面法 epigraph cutting-plane method 上镜图切平面法 lower bounds a
Hadoop 二:Hadoop来历以及Doug Cutting
一.Hadoop来历  2004年12月。Google发表了MapReduce论文,MapReduce允许跨服务器集群,运行超大规模并行计算。Doug Cutting意识到可以用MapReduce来解决Lucene的扩展问题。Google发表了GFS论文。Doug Cutting根据GFS和MapReduce的思想创建了开源Hadoop框架。2006年1月,Doug Cutting加入Yah
CSUOJ 1284 Cutting Cake(递推)
1284: Cutting Cake Description 一个蛋糕切N刀,最多能得到多少块?切的过程中不能改变任意一块蛋糕的位置。 Input 输入数据的第一行包含一个整数T (1 ,表示接下来一共有T组测试数据。 每组测试数据占一行,包含一个整数N (1 ,含义同上。 Output 用一行输出一个整数,
算法之动态规划-Rod cutting
问题描述:给定长度为n的木头,把它切分成小段卖,不同长度的木头价格不一样,求最优切法。如图1: 可以划分为如下情况 分为一份: 4 (max price:10) 分为两份 : 1 3 or 2 2 or 3 1 (max price:10) 分为三份 : 1 1 2 or 1 2 1 or 2 1 1 (max price:7) 分为四分 : 1 1 1 1 (max pric
CF--998B. Cutting
http://codeforces.com/contest/998/problem/B题意:n个数,可以在任意两个数之间截断,要求最后每个小段上奇数个数==偶数个数。每次截断的花费是abs(a[i]-a[i+1]);输出花费不超过B的情况下,最多可以截断几次思路:最多截断次数,从最小的可截断点开始截断就可以了,可以由题意知道的是,一个点左面奇数个数==偶数个数,那么剩下的一定也是,所以只需要找哪个...
UVA 10003 Cutting Sticks(切棍子)
题目:You have to cut a wood stick into pieces. The most affordable company, The Analog Cutting Machinery, Inc. (ACM), charges money according to the length of the stick being cut. Their procedure of work...
Cutting stock
1. 问题描述Suppose that you have been assigned the job of buying the plumbing pipes for a construction project. Your foreman gives you a list of the varying lengths of pipe needed, but the distributor sell