A. Payment Without Change

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.

Input

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.

Output

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

Example

input

4

1 2 3 4

1 2 3 6

5 2 6 27

3 3 5 18

output

YES

NO

NO

YES

题意

你有a个价值为n的硬币,你有b个价值为1的硬币,问你能否组成S块钱。

题解

贪心,能用a就用a对吧

代码

#include<bits/stdc++.h>
using namespace std; void solve(){
long long a,b,n,s;
cin>>a>>b>>n>>s;
long long d = s/n;
d=min(d,a);
if(b>=s-d*n){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
}
int main(){
int t;
scanf("%d",&t);
while(t--)solve();
}

Codeforces Round #598 (Div. 3) A. Payment Without Change 水题的更多相关文章

  1. Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题

    Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  ...

  2. Codeforces Round #290 (Div. 2) A. Fox And Snake 水题

    A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...

  3. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  4. Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题

    B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...

  5. Codeforces Round #368 (Div. 2) A. Brain's Photos 水题

    A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...

  6. Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题

    A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...

  7. Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题

    A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...

  8. Codeforces Round #384 (Div. 2) A. Vladik and flights 水题

    A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive pr ...

  9. Codeforces Round #379 (Div. 2) D. Anton and Chess 水题

    D. Anton and Chess 题目连接: http://codeforces.com/contest/734/problem/D Description Anton likes to play ...

随机推荐

  1. Abp RabbitMqEventBus

    RabbitMQ安装介绍查看该网址 两个App都要配置 appsettings.json { "RabbitMQ": { "Connections": { &q ...

  2. facl 用户以及Linux 终端

    FACL : Filesystem Access Control List 利用文件扩展保存额外的访问控制权限setfacl -b:Remove all -m:设定 u:UID:perm g:GID: ...

  3. python的@propert装饰器

    首先,@propert的作用是把类中的方法『变成』了属性,方便通过实例访问.propert可以有两种用法:可以把一个方法变成只读属性:可以对一些属性进行过滤. 想象这样一个场景,在实例化一个类之后,需 ...

  4. CF 1114D(538,div2) Flood Fill

    https://codeforces.com/contest/1114/problem/D 题目 给一串数字,首先选择一个位置,类似于画图,然后每一轮按照以下步骤: 可以将这个位置所在的连通块改成其他 ...

  5. Java之Math类

    概述 java.lang.Math 类包含用于执行基本数学运算的方法,如初等指数.对数.平方根和三角函数.类似这样的工具 类,其所有方法均为静态方法,并且不会创建对象,调用起来非常简单. 基本运算的方 ...

  6. 花了三个月终于把所有的 Python 库全部整理了!可以说很全面了

    库名称简介 Chardet字符编码探测器,可以自动检测文本.网页.xml的编码. colorama主要用来给文本添加各种颜色,并且非常简单易用. Prettytable主要用于在终端或浏览器端构建格式 ...

  7. [bzoj3456]城市规划:多项式,分治

    Description 刚刚解决完电力网络的问题, 阿狸又被领导的任务给难住了. 刚才说过, 阿狸的国家有n个城市, 现在国家需要在某些城市对之间建立一些贸易路线, 使得整个国家的任意两个城市都直接或 ...

  8. 日记o3o

    12.17 段考超级烂,连sts都没考过,但是今晚来机房,nj发邮件的时候也给我发了,看来是可以继续学竞赛啦,很快心,也挺不开心的,毕竟以后想要跟上文化课就要很努力了,有能力但是得去花时间啊,寒假又要 ...

  9. Spring Boot 2 快速教程:WebFlux 集成 Thymeleaf(五)

    号外:为读者持续整理了几份最新教程,覆盖了 Spring Boot.Spring Cloud.微服务架构等PDF.获取方式:关注右侧公众号"泥瓦匠BYSocket",来领取吧! 摘 ...

  10. (转)深入解析TensorFlow中滑动平均模型与代码实现

    本文链接:https://blog.csdn.net/m0_38106113/article/details/81542863 指数加权平均算法的原理 TensorFlow中的滑动平均模型使用的是滑动 ...