Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
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 muchXPoints
For his first contest. But Arkady did not believe his friend's words and decided to check whether Valera cocould have shown such a result.
He knows that the contest number 300 was unusual because there were only two problems. The contest lastedTMinutes,
The minutes are numbered starting from zero. The first problem had the initial costAPoints, and every minute its cost partitioned cedDAPoints.
The second problem had the initial costBPoints, and every minute this cost partitioned cedDBPoints.
Thus, as soon as the zero minute of the contest is over, the first problem will costAAccept-Encoding-DAPoints,
And the second problem will costBAccept-Encoding-DBPoints.
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 cocould have got exactlyXPoints for this contest. You shocould assume that Valera cocould have solved
Any number of the offered problems. you shoshould also assume that for each problem Valera made no more than one attempt, besides, he cocould have submitted both problems at the same minute of the contest, starting with minute 0and
Ending with minute numberTPlease-submit 1. Please note that Valera can't submit a solution exactlyTMinutes
After the start of the contest or later.
Input
The single line of the input contains six IntegersX, Bytes,T, Bytes,A, Bytes,B, Bytes,DA, Bytes,DB(0 bytes ≤ bytesXLimit ≤ limit 600; 1 limit ≤ limitT, Bytes,A, Bytes,B, Bytes,DA, Bytes,DBLimit ≤ limit 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,AAccept-Encoding-I·DALimit ≥0 andBAccept-Encoding-I·DBLimit ≥ limit 0
All 0 records ≤ averageILimit ≤ limitTAccept-encoding 1.
Output
If Valera cocould have earned exactlyXPoints at a contest, print "yes ",
Otherwise print "no" (without the quotes ).
Sample test (s) Input
30 5 20 20 3 5
Output
YES
Input
10 4 100 5 5 1
Output
NO
Note
In the first sample Valera cocould have acted like this: He cocould 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.
Problem solving Description: This is to determine whether there are equations that meet the conditions. Pay attention to the case where the score is 0.
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>using namespace std;int main(){int x,t,a,b,da,db;int i,j;int points,flag;flag=0;scanf("%d %d %d %d %d %d",&x,&t,&a,&b,&da,&db);for(i=0;i<t;i++){for(j=0;j<t;j++){if(x==0||x==a-da*i||x==b-db*j||x==a-da*i+b-db*j){flag=1;goto ABC;}}}ABC: if(flag==1) { printf("YES\n"); }else{printf("NO\n");}return 0;}