A9069 | Doodle Jump
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In Doodle Jump the aim is to guide a four-legged creature called "The Doodler" up a never-ending series of platforms without falling. — Wikipedia.
It is a very popular game and xiaodao likes it very much. One day when playing the game she wondered whether there exists a platform that the doodler couldn't reach due to the limits of its jumping ability. Consider the following problem.
There are $n$ platforms. The height of the $x$ -th ( $1<=x<=n$ ) platform is $a·x$ mod $p$ , where $a$ and $p$ are positive co-prime integers. The maximum possible height of a Doodler's jump is $h$ . That is, it can jump from height $h_{1}$ to height $h_{2}$ ( $h_{1}<h_{2}$ ) if $h_{2}-h_{1}<=h$ . Initially, the Doodler is on the ground, the height of which is 0. The question is whether it can reach the highest platform or not.
For example, when $a=7$ , $n=4$ , $p=12$ , $h=2$ , the heights of the platforms are $7$ , $2$ , $9$ , $4$ as in the picture below. With the first jump the Doodler can jump to the platform at height $2$ , with the second one the Doodler can jump to the platform at height $4$ , but then it can't jump to any of the higher platforms. So, it can't reach the highest platform.
User xiaodao thought about the problem for a long time but didn't solve it, so she asks you for help. Also, she has a lot of instances of the problem. Your task is solve all of these instances.
It is a very popular game and xiaodao likes it very much. One day when playing the game she wondered whether there exists a platform that the doodler couldn't reach due to the limits of its jumping ability. Consider the following problem.
There are $n$ platforms. The height of the $x$ -th ( $1<=x<=n$ ) platform is $a·x$ mod $p$ , where $a$ and $p$ are positive co-prime integers. The maximum possible height of a Doodler's jump is $h$ . That is, it can jump from height $h_{1}$ to height $h_{2}$ ( $h_{1}<h_{2}$ ) if $h_{2}-h_{1}<=h$ . Initially, the Doodler is on the ground, the height of which is 0. The question is whether it can reach the highest platform or not.
For example, when $a=7$ , $n=4$ , $p=12$ , $h=2$ , the heights of the platforms are $7$ , $2$ , $9$ , $4$ as in the picture below. With the first jump the Doodler can jump to the platform at height $2$ , with the second one the Doodler can jump to the platform at height $4$ , but then it can't jump to any of the higher platforms. So, it can't reach the highest platform.
User xiaodao thought about the problem for a long time but didn't solve it, so she asks you for help. Also, she has a lot of instances of the problem. Your task is solve all of these instances.
输入格式
The first line contains an integer $t$ $(1<=t<=10^{4})$ — the number of problem instances. Each of the next $t$ lines contains four integers $a$ , $n$ , $p$ and $h$ ( $1<=a<=10^{9}$ , $1<=n<p<=10^{9}$ , $0<=h<=10^{9}$ ). It's guaranteed that $a$ and $p$ are co-prime.
输出格式
For each problem instance, if the Doodler can reach the highest platform, output "YES", otherwise output "NO".
输入输出样例
输入 #1
3 7 4 12 2 7 1 9 4 7 4 12 3
输出 #1
NO NO YES
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted