A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as x points for his first contest. But Arkady did not believe his friend’s words and decided to check whether Valera could have shown such a result.
He knows that the contest number 300 was unusual because there were only two problems. The contest lasted for t minutes, the minutes are numbered starting from zero. The first problem had the initial cost of a points, and every minute its cost reduced by da points. The second problem had the initial cost of b points, and every minute this cost reduced by db points. Thus, as soon as the zero minute of the contest is over, the first problem will cost a - da points, and the second problem will cost b - db points. It is guaranteed that at any moment of the contest each problem has a non-negative cost.
Arkady asks you to find out whether Valera could have got exactly x points for this contest. You should assume that Valera could have solved any number of the offered problems. You should also assume that for each problem Valera made no more than one attempt, besides, he could have submitted both problems at the same minute of the contest, starting with minute 0 and ending with minute number t - 1. Please note that Valera can’t submit a solution exactly t minutes after the start of the contest or later.
Input
The single line of the input contains six integers x, t, a, b, da, db (0 ≤ x ≤ 600; 1 ≤ t, a, b, da, db ≤ 300) — Valera’s result, the contest’s duration, the initial cost of the first problem, the initial cost of the second problem, the number of points that the first and the second problem lose per minute, correspondingly.
It is guaranteed that at each minute of the contest each problem has a non-negative cost, that is, a - i·da ≥ 0 and b - i·db ≥ 0 for all 0 ≤ i ≤ t - 1.
Output
If Valera could have earned exactly x points at a contest, print “YES”, otherwise print “NO” (without the quotes).
Examples
Input
30 5 20 20 3 5
Output
YES
Input
10 4 100 5 5 1
Output
NO
Note
In the first sample Valera could have acted like this: he could have submitted the first problem at minute 0 and the second problem — at minute 2. Then the first problem brings him 20 points and the second problem brings him 10 points, that in total gives the required 30 points.
题意:Valera说自己在比赛中得了x分数,比赛中有a,b两道题,如果做出了题目会因为交的时间而减去 da(db)*i 分数。如果没有做出来就不说了。
思路:比赛时想的不完整,以为分数是由满分因为时间而减少,实际上前提是做了该题目。所以一共有三种情况:1.一题也没做出来。2.只做出了一题(任一)。3.做出了两题。
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int x,t,a,b,da,db;
while(~scanf("%d%d%d%d%d%d",&x,&t,&a,&b,&da,&db))
{
int flag=1;
for(int i=0; i<t; i++)
for(int j=0; j<t; j++)
{
if(x==0||x==a-da*i||x==b-db*j||x==a+b-da*i-db*j)//一题都没做出来,只做出了一题,做出了两题
{
flag=0;
}
}
if(!flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}