CF1804C.Pull Your Luck
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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?
詹姆斯出差期间,维斯珀闲来无事,开始探索这家传奇赌场“皇家赌场”为热衷于竞争性编程的人们所提供的特别项目。
她的注意力被一款全新的轮盘游戏——“凭运气拉动”(Pull Your Luck)所吸引,该游戏的运作方式颇为奇特。轮盘由 n 个扇区组成,编号从 0 到 n−1。游戏中没有小球,获胜扇区由一个静止不动、始终指向某一扇区的箭头决定。扇区编号按自然顺序排列,且轮盘始终沿编号递增的方向旋转。这意味着:对所有 i(其中 0≤i≤n−2),扇区 i+1 紧接在扇区 i 之后;而扇区 0 则紧接在扇区 n−1 之后。
下注完成后,玩家可自行拉动触发拉杆,使轮盘开始旋转。若玩家首次拉动所施加的力为正整数 f,则轮盘将旋转 f 秒:第 1 秒前进 f 个扇区,第 2 秒前进 f−1 个扇区,第 3 秒前进 f−2 个扇区,依此类推,直至完全停止。轮盘停止后,箭头所指的扇区即为获胜扇区。
目前,轮盘上的箭头正指向扇区 x。维斯珀知道,她可以施加任意大小为 1 至 p(含端点)的整数力来拉动拉杆(注意:不允许以 0 力拉动,即必须拉动)。若获胜扇区为 0,则可赢得最高奖项。现在维斯珀想知道:她能否仅拉动一次触发拉杆,就使得扇区 0 成为获胜扇区?
输入格式
The first line of the input contains a single integer t (1≤t≤104) — 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≤n≤105, 0≤x<n, 1≤p≤109). 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⋅105.
输入的第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。随后是 t 行,每行包含一个测试用例的描述。
每个测试用例的描述由三个整数 n、x 和 p 组成(3≤n≤105,0≤x<n,1≤p≤109),分别表示转盘上的扇区数量、箭头当前指向的扇区编号,以及 Vesper 拉动手柄所能施加的最大力度。
保证所有测试用例中 n 的总和不超过 2⋅105。
输出格式
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.
输出 t 行,其中第 i 行应包含第 i 个测试用例的答案。如果存在一种方式,按顺序依次施加大小为 1 到 p 的整数力来拉动操纵杆,使得扇区 0 获胜,则输出 "Yes";否则输出 "No"。
你可以以任意大小写形式输出答案(大写或小写均可)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均会被识别为肯定回答。
输入输出样例
输入#1
7 5 2 1 5 2 2 10 0 100 11 7 100 3 1 1000 31 0 10 100 49 7
输出#1
No Yes Yes Yes No No No
说明/提示
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.
在第一个例子中,拉动拉杆的唯一可能的力为 1。该力不足以使指针指向第 0 个扇区,至少需要力 2 才能实现这一点。
在第二个例子中,维斯珀可以以力 2 拉动拉杆,此时轮盘将向前旋转 2+1=3 个扇区,从而使指针指向第 0 个扇区。
在第三个例子中,维斯珀可以以力 4 拉动拉杆,此时轮盘将旋转 4+3+2+1=10 个扇区,并再次指向第 0 个扇区。
在第四个例子中,维斯珀可以以力 5 拉动拉杆,此时轮盘将旋转 5+4+3+2+1=15 个扇区。这将使轮盘完成一整圈(即 12 个扇区)后再额外旋转 4 个扇区。
在第五个例子中,无论维斯珀选择以多大的力拉动拉杆,她都只能使第 1 和第 2 个扇区获胜。
输入解题思路,AI测评打分。不知道怎么写?