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();
}

最新文章

  1. Windows Azure Virtual Machine (30) 修改Azure VM 的Subnet
  2. OpenGL 纹理贴图
  3. uva 11324 The Largest Clique (Tarjan+记忆化)
  4. hdu 5046 Airport 二分+重复覆盖
  5. iOS App3D Touch快捷键的静态以及动态设置详细使用
  6. MyEclipse提示
  7. C#迭代语句、跳转语句--C#基础
  8. 机器学习(1) - TensorflowSharp 简单使用与KNN识别MNIST流程
  9. Gson序列化对象如何忽略字段
  10. Windows下createfile函数用GENERIC_READ访问模式打不开磁盘
  11. 如何使用Docker部署一个Go Web应用程序
  12. JavaScript对象的指向问题
  13. sonar-代码扫描
  14. OO第一单元三次作业总结
  15. el表达式获取对象属性值 返回值类型
  16. Java 静态方法不能重写但可以被子类静态方法覆盖
  17. STM32 SPI接口的NSS引脚
  18. ASP.NET Core 2.0 MVC 发布部署--------- linux安装.NET CORE SDK具体操作链接以及操作总细节
  19. css实现图标移上图标弹跳效果
  20. 安装mezzanine时报:storing debug log for failure【已解决】

热门文章

  1. js-01-基础知识
  2. 云K8S - AWS容器库ECR(ERS)编排ECS-EKS以及阿里云编排ACS-ACK
  3. redis5.0.0功能介绍以及主从集群、哨兵搭建
  4. C#后台架构师成长之路-基础体系篇章大纲
  5. vue element-ui父列表和子列表同时出现时的bug
  6. 设计模式-工厂模式(Factory)(创建型模式)
  7. Python 分析到底是谁操纵《庆余年》上了热搜?
  8. 【RTOS】为H7配套的uCOS-III模板也是可以用于MDK AC6的,提供个模板
  9. IT兄弟连 HTML5教程 多媒体应用 小结及习题
  10. 基于appium的fixture应用之代码重构