102863: [AtCoder]ABC286 D - Money in Hand

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:3 Solved:0

Description

Score : $400$ points

Problem Statement

Takahashi has $N$ kinds of coins; specifically, for $1\leq i\leq N$, he has $B_i$ coins worth $A_i$ yen (the currency in Japan) each.

Determine if Takahashi can pay exactly $X$ yen (without change) with the coins he currently has.

Constraints

  • $1\leq N\leq 50$
  • $1\leq X\leq 10^4$
  • $1\leq A_i\leq 100$
  • $1\leq B_i\leq 50$
  • $A_i$ are pairwise distinct.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

$N$ $X$
$A_1$ $B_1$
$A_2$ $B_2$
$\vdots$
$A_N$ $B_N$

Output

Print Yes if Takahashi can pay exactly $X$ yen with the coins he currently has; print No otherwise.


Sample Input 1

2 19
2 3
5 6

Sample Output 1

Yes

Takahashi has three $2$-yen coins and six $5$-yen coins. He can use two $2$-yen coins and three $5$-yen coins to pay exactly $2\times 2+5\times 3=19$ yen. Thus, Yes should be printed.


Sample Input 2

2 18
2 3
5 6

Sample Output 2

No

There is no combination of the coins that he can use to pay exactly $18$ yen. Thus, No should be printed.


Sample Input 3

3 1001
1 1
2 1
100 10

Sample Output 3

Yes

He need not use all kinds of coins.

Input

题意翻译

有 $n$ 种纸币,其中对于第 $i(1\le i\le n)$ 种纸币,它的面值是 $a_i$ 元,我们有 $b_i$ 张这种纸币。 请求出在不找零的情况下,用这些纸币能否**正好**付 $x$ 元,如果能则输出 `Yes`,不能则输出 `No`。 保证 $1 \le n \le 50, 1\le x \le 10^4, 1\le a_i \le 100, 1\le b_i\le 50$。 翻译提供者@\_\_Allen\_123\_\_

Output

得分:400分 部分 问题描述 Takahashi 有 N 种硬币;具体来说,对于 1≤i≤N,他有 B_i 枚面值为 A_i 日元(日本的货币单位)的硬币。 确定Takahashi是否可以用他目前拥有的硬币正好支付 X 日元(无需找零)。 部分 约束 1≤N≤50 1≤X≤10^4 1≤A_i≤100 1≤B_i≤50 A_i 两两不同。 输入中的所有值都是整数。 部分 输入 输入将从标准输入按以下格式给出: N X A_1 B_1 A_2 B_2 ⋮ A_N B_N 部分 输出 如果Takahashi可以用他目前拥有的硬币正好支付 X 日元,则打印Yes;否则打印No。 部分 样例输入 1 2 19 2 3 5 6 部分 样例输出 1 Yes Takahashi有三枚 2 日元硬币和六枚 5 日元硬币。他可以使用两枚 2 日元硬币和三枚 5 日元硬币来支付正好 2×2+5×3=19 日元。因此,应该打印Yes。 部分 样例输入 2 2 18 2 3 5 6 部分 样例输出 2 No 没有他可以用来正好支付 18 日元的硬币组合。因此,应该打印No。 部分 样例输入 3 3 1001 1 1 2 1 100 10 部分 样例输出 3 Yes 他不必使用所有种类的硬币。

加入题单

算法标签: