CF2180A.Carnival Wheel
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have a prize wheel divided into l sections, numbered from 0 to l−1. The sections are arranged in a circle, so after section l−1, the numbering continues again from section 0.
Initially, the prize pointer is at section a. Each time you spin the wheel, the pointer moves exactly b sections forward. That is, after one spin, the pointer moves from section a to section (a+b)modl, after two spins to (a+2b)modl, and so on∗.
You may spin the wheel any number of times (including zero). After you stop, the section where the pointer finally lands determines your prize: you receive an amount equal to the number of that section.
What is the maximum prize you can obtain?
∗Here, xmody denotes the remainder from dividing x by y.
你有一个被分为 l 个扇形区域的奖品转盘,区域编号从 0 到 l−1。这些区域呈环形排列,因此在区域 l−1 之后,编号再次从区域 0 开始。
初始时,指针位于区域 a。每次旋转转盘,指针恰好向前移动 b 个区域。即:旋转一次后,指针从区域 a 移动到区域 (a+b)modl;旋转两次后移动到 (a+2b)modl,依此类推∗。
你可以任意次数地旋转转盘(包括零次)。当你停止旋转后,指针最终停留的区域编号即为你获得的奖品金额。
你能获得的最大奖品金额是多少?
∗此处,xmody 表示 x 除以 y 所得的余数。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤500). The description of the test cases follows.
The first line of each test case contains three integers l,a, and b (1≤l,b≤5000, 0≤a≤l−1).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤500)。随后是各测试用例的描述。
每个测试用例的第一行包含三个整数 l、a 和 b(1≤l,b≤5000,0≤a≤l−1)。
输出格式
For each test case, output the maximum prize that can be obtained.
对于每个测试用例,输出能够获得的最大奖品价值。
输入输出样例
输入#1
4 5 3 2 2 0 6 8 2 4 100 0 1
输出#1
4 0 6 99
说明/提示
In the first test case, by spinning the wheel three times and then claiming the reward, you can obtain a maximum value of 4. The sequence of pointer positions is: 3,0,2,4,1,3,0,…
In the second test case, the pointer will remain on section 0 indefinitely.
In the fourth test case, with b=1 and starting from section 0, the pointer will iterate over all sections, including the last one.
在第一个测试用例中,通过旋转转盘三次后领取奖励,可以获得最大值 4。指针位置序列为:3,0,2,4,1,3,0,…
在第二个测试用例中,指针将无限停留在第 0 区域。
在第四个测试用例中,当 b=1 且从第 0 区域开始时,指针将遍历所有区域(包括最后一个区域)。
输入解题思路,AI测评打分。不知道怎么写?