atcoder#ABC286D. [ABC286D] Money in Hand
[ABC286D] Money in Hand
Score : points
Problem Statement
Takahashi has kinds of coins; specifically, for , he has coins worth yen (the currency in Japan) each.
Determine if Takahashi can pay exactly yen (without change) with the coins he currently has.
Constraints
- are pairwise distinct.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if Takahashi can pay exactly yen with the coins he currently has;
print No
otherwise.
2 19
2 3
5 6
Yes
Takahashi has three -yen coins and six -yen coins.
He can use two -yen coins and three -yen coins to pay exactly yen.
Thus, Yes
should be printed.
2 18
2 3
5 6
No
There is no combination of the coins that he can use to pay exactly yen.
Thus, No
should be printed.
3 1001
1 1
2 1
100 10
Yes
He need not use all kinds of coins.