310244: CF1804C. Pull Your Luck

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Pull Your Lucktime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

While James is gone on business, Vesper takes her time and explores what the legendary Casino Royale has to offer to people who are fond of competitive programming.

Her attention was grabbed by the very new "Pull Your Luck" roulette which functions in a pretty peculiar way. The roulette's wheel consists of $n$ sectors number from $0$ to $n - 1$. There is no ball and the winning sector is determined by a static arrow pointing to one of the sectors. Sectors' indexes go in the natural order and the wheel always spins in the direction of indexes increment. That means that sector $i + 1$ goes right after sector $i$ for all $i$ from $0$ to $n - 2$, and sector $0$ goes right after sector $n - 1$.

After a bet is made, the player is allowed to pull the triggering handle herself and cause the wheel to spin. If the player's initial pull is made with the force equal to positive integer $f$, the wheel will spin for $f$ seconds. During the first second it will advance $f$ sectors, the next second it will advance $f - 1$ sectors, then $f - 2$ sectors, and so on until it comes to a complete stop. After the wheel comes to a complete stop, the sector which the arrow is pointing to is the winning one.

The roulette's arrow currently points at sector $x$. Vesper knows that she can pull the handle with any integer force from $1$ to $p$ inclusive. Note that it is not allowed to pull the handle with force $0$, i. e. not pull it all. The biggest prize is awarded if the winning sector is $0$. Now Vesper wonders if she can make sector $0$ win by pulling the triggering handle exactly once?

Input

The first line of the input contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. Then follow $t$ lines containing one test description each.

Each test description consists of three integers $n$, $x$ and $p$ ($3 \leq n \leq 10^5$, $0 \leq x < n$, $1 \leq p \leq 10^9$). They are the number of sectors on the wheel, the current sector the arrow points at, and the maximum force that Vesper can pull the handle with, respectively.

It is guaranteed that the sum of $n$ over all test cases doesn't exceed $2 \cdot 10^5$.

Output

Print $t$ lines, the $i$-th line should contain the answer for the $i$-th test case. If it is possible to pull the handle with the integer force from $1$ to $p$ in order to make sector $0$ win, print "Yes". Otherwise, print "No".

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

ExampleInput
7
5 2 1
5 2 2
10 0 100
11 7 100
3 1 1000
31 0 10
100 49 7
Output
No
Yes
Yes
Yes
No
No
No
Note

In the first example, the only possible way to pull the handle is with force $1$. That is not enough to make the arrow point at sector $0$, at least force $2$ is required to do so.

In the second example, Vesper can pull the handle with the force $2$ so the wheel will spin $2 + 1 = 3$ sectors ahead and the arrow will point at sector $0$.

In the third example, Vesper can pull the handle with the force $4$ so the wheel will spin $4 + 3 + 2 + 1 = 10$ sectors and will point at sector $0$ again.

In the fourth example, Vesper can pull the handle with the force $5$ so the wheel will spin $5 + 4 + 3 + 2 + 1 = 15$ sectors. That will make the wheel make one full turn plus $4$ more sectors.

In the fifth example, whatever force Vesper chooses to pull the handle with, she can only make sectors $1$ and $2$ win.

Input

题意翻译

一个转盘有 $n$ 个格子分别为 $0$ $1$ $2$ $\cdots$ $n-1$,初始时在 $x$ 号格子,你希望转动一次转盘来使它回到 $0$ 号位置,(转盘转到 $n-1$ 后再转就会回到 $0$)。 你有一个可以使出的最大力气 $p$,你可以使出任意的力气 $f$ 满足 $f\leq p$。然后,转盘会转动 $f$ 秒,第一秒转动 $f$ 个格子,第二秒转动 $f-1$ 个格子,以此类推,第 $f$ 秒就会转动 $1$ 个格子,之后转盘就会停止转动。 现在给你 $n$,$x$,$p$,请你判断能否使出一次一个力气 $f$,使得转盘能够转到 $0$ 号格子,$T$ 组数据,用 ``No`` 和 ``Yes`` 回答 数据范围: $1\leq T\leq 10^4$ 单组数据中 $n\leq 10^5$ 所有数据中 $n$ 之和小于 $2\times 10^5$ $1\leq p\leq 10^9$

Output

题目大意:
题目描述了一个名为 "Pull Your Luck" 的轮盘游戏,轮盘有 n 个扇区,编号从 0 到 n-1。轮盘上有一个静态箭头指向某个扇区。玩家可以拉动一个触发手柄,使轮盘旋转。如果玩家初始拉动时的力是正整数 f,轮盘将旋转 f 秒。在第一秒,轮盘会前进 f 个扇区,接下来的一秒会前进 f-1 个扇区,以此类推,直到轮盘完全停止。轮盘停止后,箭头指向的扇区就是赢的扇区。当前箭头指向扇区 x,玩家可以拉动手柄的力从 1 到 p。要求判断是否可以通过恰好拉动一次手柄使扇区 0 获胜。

输入输出数据格式:
输入:
- 第一行包含一个整数 t(1 ≤ t ≤ 10^4),表示测试用例的数量。
- 接下来 t 行,每行包含三个整数 n、x 和 p(3 ≤ n ≤ 10^5,0 ≤ x < n,1 ≤ p ≤ 10^9),分别表示轮盘的扇区数、箭头指向的扇区编号和玩家可以拉动手柄的最大力。

输出:
- 输出 t 行,每行对应一个测试用例的答案。如果可以通过拉动 1 到 p 的力使扇区 0 获胜,输出 "Yes",否则输出 "No"。

注意:输出答案时大小写不敏感。题目大意: 题目描述了一个名为 "Pull Your Luck" 的轮盘游戏,轮盘有 n 个扇区,编号从 0 到 n-1。轮盘上有一个静态箭头指向某个扇区。玩家可以拉动一个触发手柄,使轮盘旋转。如果玩家初始拉动时的力是正整数 f,轮盘将旋转 f 秒。在第一秒,轮盘会前进 f 个扇区,接下来的一秒会前进 f-1 个扇区,以此类推,直到轮盘完全停止。轮盘停止后,箭头指向的扇区就是赢的扇区。当前箭头指向扇区 x,玩家可以拉动手柄的力从 1 到 p。要求判断是否可以通过恰好拉动一次手柄使扇区 0 获胜。 输入输出数据格式: 输入: - 第一行包含一个整数 t(1 ≤ t ≤ 10^4),表示测试用例的数量。 - 接下来 t 行,每行包含三个整数 n、x 和 p(3 ≤ n ≤ 10^5,0 ≤ x < n,1 ≤ p ≤ 10^9),分别表示轮盘的扇区数、箭头指向的扇区编号和玩家可以拉动手柄的最大力。 输出: - 输出 t 行,每行对应一个测试用例的答案。如果可以通过拉动 1 到 p 的力使扇区 0 获胜,输出 "Yes",否则输出 "No"。 注意:输出答案时大小写不敏感。

加入题单

算法标签: