题目链接:Problem - 1256A - Codeforces
解题思路:
题目的大致意思就是手中的硬币数拿出若干枚正好等于s,分三种情况
.如果n > s && b < s,输出no
.如果b >= s,输出yes
.如果n * (a < (s / n) ? a : (s / n)) + b >= s,也就是找到小于等于s的n面值的硬币的最大数量,前提是不超过a
下面是c++代码:
#include<iostream>
using namespace std;
int main()
{int t;long long a, b, n, s;cin >> t;while (t != 0) {cin >> a >> b >> n >> s;long long sum = n;if (n > s && b < s) {cout << "NO" << endl;t--;continue;}if (b >= s) {cout << "YES" << endl;}else if (n * (a < (s / n) ? a : (s / n)) + b >= s) {cout << "YES" << endl;}else {cout << "NO" << endl;}t--;}return 0;
}