time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
You have aa coins of value nn and bb coins of value 11. You always pay in exact change, so you want to know if there exist such xx and yy that if you take xx (0≤x≤a0≤x≤a) coins of value nn and yy (0≤y≤b0≤y≤b) coins of value 11, then the total value of taken coins will be SS.
You have to answer qq independent test cases.
Input
The first line of the input contains one integer qq (1≤q≤1041≤q≤104) — the number of test cases. Then qq test cases follow.
The only line of the test case contains four integers aa, bb, nn and SS (1≤a,b,n,S≤1091≤a,b,n,S≤109) — the number of coins of value nn, the number of coins of value 11, the value nn and the required total value.
Output
For the ii-th test case print the answer on it — YES (without quotes) if there exist such xx and yy that if you take xx coins of value nn and yy coins of value 11, then the total value of taken coins will be SS, and NO otherwise.
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
Example
input
Copy
4 1 2 3 4 1 2 3 6 5 2 6 27 3 3 5 18
output
Copy
YES NO NO YES
解题说明:水题,按照题目意思进行判断即可。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int q;
long long a, b, n, s;
scanf("%d", &q);
while (q--)
{
scanf("%lld%lld%lld%lld", &a, &b, &n, &s);
if (a*n + b >= s)
{
s = s % n;
if (s <= b)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
else
{
printf("NO\n");
}
}
return 0;
}