CF203A.Two Problems

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 xx 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 300300 was unusual because there were only two problems. The contest lasted for tt minutes, the minutes are numbered starting from zero. The first problem had the initial cost of aa points, and every minute its cost reduced by dad_{a} points. The second problem had the initial cost of bb points, and every minute this cost reduced by dbd_{b} points. Thus, as soon as the zero minute of the contest is over, the first problem will cost adaa-d_{a} points, and the second problem will cost bdbb-d_{b} 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 xx 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 00 and ending with minute number t1t-1 . Please note that Valera can't submit a solution exactly tt minutes after the start of the contest or later.

输入格式

The single line of the input contains six integers x,t,a,b,da,dbx,t,a,b,d_{a},d_{b} (0<=x<=600; 1<=t,a,b,da,db<=300)(0<=x<=600; 1<=t,a,b,d_{a},d_{b}<=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, aida>=0a-i·d_{a}>=0 and bidb>=0b-i·d_{b}>=0 for all 0<=i<=t10<=i<=t-1 .

输出格式

If Valera could have earned exactly xx points at a contest, print "YES", otherwise print "NO" (without the quotes).

输入输出样例

  • 输入#1

    30 5 20 20 3 5
    

    输出#1

    YES
    
  • 输入#2

    10 4 100 5 5 1
    

    输出#2

    NO
    

说明/提示

In the first sample Valera could have acted like this: he could have submitted the first problem at minute 00 and the second problem — at minute 22 . Then the first problem brings him 2020 points and the second problem brings him 1010 points, that in total gives the required 3030 points.

首页