CF1256A.Payment Without Change
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have a coins of value n and b coins of value 1. You always pay in exact change, so you want to know if there exist such x and y that if you take x (0≤x≤a) coins of value n and y (0≤y≤b) coins of value 1, then the total value of taken coins will be S.
You have to answer q independent test cases.
你有 a 枚面值为 n 的硬币和 b 枚面值为 1 的硬币。你总是支付恰好所需的金额,因此你想知道是否存在满足条件的 x 和 y:取 x(其中 0≤x≤a)枚面值为 n 的硬币和 y(其中 0≤y≤b)枚面值为 1 的硬币,使得所取硬币的总价值恰好为 S。
你需要回答 q 个相互独立的测试用例。
输入格式
The first line of the input contains one integer q (1≤q≤104) — the number of test cases. Then q test cases follow.
The only line of the test case contains four integers a, b, n and S (1≤a,b,n,S≤109) — the number of coins of value n, the number of coins of value 1, the value n and the required total value.
输入的第一行包含一个整数 q(1≤q≤104),表示测试用例的数量。接下来是 q 个测试用例。
每个测试用例仅一行,包含四个整数 a、b、n 和 S(1≤a,b,n,S≤109),分别表示面值为 n 的硬币数量、面值为 1 的硬币数量、面值 n 以及所需的总金额。
输出格式
For the i-th test case print the answer on it — YES (without quotes) if there exist such x and y that if you take x coins of value n and y coins of value 1, then the total value of taken coins will be S, 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).
对于第 i 个测试用例,请输出对应的答案:若存在非负整数 x 和 y,使得取 x 枚面值为 n 的硬币和 y 枚面值为 1 的硬币后,总价值恰好为 S,则输出 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测评打分。不知道怎么写?