CF1256A.Payment Without Change

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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 \le x \le a) coins of value nn and yy (0≤y≤b0 \le y \le b) coins of value 11, then the total value of taken coins will be SS.

You have to answer qq independent test cases.

你有 aa 枚面值为 nn 的硬币和 bb 枚面值为 11 的硬币。你总是支付恰好所需的金额,因此你想知道是否存在满足条件的 xx 和 yy:取 xx(其中 0≤x≤a0 \le x \le a)枚面值为 nn 的硬币和 yy(其中 0≤y≤b0 \le y \le b)枚面值为 11 的硬币,使得所取硬币的总价值恰好为 SS。

你需要回答 qq 个相互独立的测试用例。

输入格式

The first line of the input contains one integer qq (1≤q≤1041 \le q \le 10^4) — 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 \le a, b, n, S \le 10^9) — the number of coins of value nn, the number of coins of value 11, the value nn and the required total value.

输入的第一行包含一个整数 qq(1≤q≤1041 \le q \le 10^4),表示测试用例的数量。接下来是 qq 个测试用例。

每个测试用例仅一行,包含四个整数 aa、bb、nn 和 SS(1≤a,b,n,S≤1091 \le a, b, n, S \le 10^9),分别表示面值为 nn 的硬币数量、面值为 11 的硬币数量、面值 nn 以及所需的总金额。

输出格式

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).

对于第 ii 个测试用例,请输出对应的答案:若存在非负整数 xx 和 yy,使得取 xx 枚面值为 nn 的硬币和 yy 枚面值为 11 的硬币后,总价值恰好为 SS,则输出 YES(不带引号);否则输出 NO。

你可以以任意大小写形式输出每个字母(例如,字符串 yEs、yes、Yes 和 YES 均会被识别为肯定回答)。

输入输出样例

  • 输入#1

    4
    1 2 3 4
    1 2 3 6
    5 2 6 27
    3 3 5 18

    输出#1

    YES
    NO
    NO
    YES

输入解题思路,AI测评打分。不知道怎么写?

首页