CF203A.Two Problems
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
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 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 d__a points. The second problem had the initial cost of b points, and every minute this cost reduced by d__b points. Thus, as soon as the zero minute of the contest is over, the first problem will cost a - d__a points, and the second problem will cost b - 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 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.
一名男孩瓦列拉(Valera)在 Codeforces 网站上注册账号名为 Valera,并参加了他的第一场 Codeforces 比赛:Codeforces Round #300。他向朋友阿尔卡季(Arkady)吹嘘自己在这场比赛中获得了整整 x 分。但阿尔卡季并不相信朋友的话,决定验证瓦列拉是否真有可能取得如此成绩。
他了解到第 300 场比赛比较特殊,仅有两道题目。整场比赛持续 t 分钟,分钟编号从 0 开始。第一题初始分值为 a 分,此后每分钟分值减少 da 分;第二题初始分值为 b 分,此后每分钟分值减少 db 分。因此,在比赛开始后的第 0 分钟结束时(即进入第 1 分钟时),第一题分值变为 a−da 分,第二题分值变为 b−db 分。题目保证:在比赛的任意时刻,每道题的分值均为非负数。
阿尔卡季请你判断:瓦列拉是否有可能恰好获得 x 分?你应假设瓦列拉可以解决所提供的任意数量的题目(即:0 道、1 道或 2 道)。同时假设:对于每道题,瓦列拉至多提交一次解答;此外,他可以在比赛的同一分钟(从第 0 分钟起,至第 t−1 分钟止)提交两道题的解答。请注意:瓦列拉不能在比赛开始后恰好 t 分钟或更晚提交解答。
输入格式
The single line of the input contains six integers x, t, a, b, d__a, d__b (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, a - i·d__a ≥ 0 and b - i·d__b ≥ 0 for all 0 ≤ i ≤ t - 1.
输入仅有一行,包含六个整数 x、t、a、b、da、db(0 ≤ x ≤ 600;1 ≤ t,a,b,da,db ≤ 300)—— 分别表示瓦莱拉的得分、比赛时长、第一道题的初始分值、第二道题的初始分值、第一道题和第二道题每分钟分别减少的分值。
保证在比赛的每一分钟,每道题的分值均为非负数,即对所有 0 ≤ i ≤ t − 1,均有 a − i ⋅ da ≥ 0 且 b − i ⋅ db ≥ 0。
输出格式
If Valera could have earned exactly x points at a contest, print "YES", otherwise print "NO" (without the quotes).
如果瓦列拉在比赛中恰好可以获得 x 分,则输出 "YES",否则输出 "NO"(不带引号)。
输入输出样例
输入#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 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.
在第一个样例中,瓦莱拉可以这样操作:他可以在第 0 分钟提交第一个问题,第 2 分钟提交第二个问题。此时第一个问题为他带来 20 分,第二个问题为他带来 10 分,总计恰好为所需的 30 分。
输入解题思路,AI测评打分。不知道怎么写?