编程介的小学生 2017-09-09 15:43 采纳率: 20.5%
浏览 750
已采纳

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条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝