CF2266B.Three Piles
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice and Bob are playing a game with three piles of stones. Initially, Alice has a stones, Bob has b stones, and the third pile contains c stones.
Alice and Bob take turns, with Alice going first. On each turn, the current player may take any number of stones from the third pile, possibly zero, and add them to their own pile.
If both players take zero stones on two consecutive turns, the game ends.
Let A and B be the final numbers of stones Alice and Bob have, respectively. The score of the game is ∣A−B∣.
Alice wants to maximize the score, while Bob wants to minimize it. Assuming both players play optimally, find the final score.
爱丽丝和鲍勃正在玩一个涉及三堆石子的游戏。初始时,爱丽丝有 a 颗石子,鲍勃有 b 颗石子,第三堆石子包含 c 颗石子。
爱丽丝和鲍勃轮流进行操作,爱丽丝先手。在每一轮中,当前玩家可以从第三堆中取走任意数量的石子(可以为零),并将这些石子加到自己的石子堆中。
如果双方连续两轮均未从第三堆取石子(即均取零颗),则游戏结束。
设 A 和 B 分别为游戏结束时爱丽丝和鲍勃所拥有的石子总数。本局游戏的得分为 ∣A−B∣。
爱丽丝希望最大化该得分,而鲍勃希望最小化该得分。假设双方均采取最优策略,求最终的得分。
输入格式
The first line contains an integer t (1≤t≤104) — the number of test cases.
Each test case contains three integers a, b, and c (0≤a,b,c≤109) — the initial numbers of stones Alice has, Bob has, and the third pile has, respectively.
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
每个测试用例包含三个整数 a、b 和 c(0≤a,b,c≤109)—— 分别表示爱丽丝初始拥有的石子数、鲍勃初始拥有的石子数以及第三堆石子的初始数量。
输出格式
For each test case, output one integer — the final score if both players play optimally.
It is important to use a 64-bit integer type, such as long long in C++.
对于每个测试用例,输出一个整数——即双方均采取最优策略时的最终得分。
务必使用 64 位整数类型,例如 C++ 中的 long long。
输入输出样例
输入#1
5 3 6 3 3 6 10 5 5 4 2 5 6 67676767 41414141 998244353
输出#1
3 7 4 3 1024506979
说明/提示
In the first test case, Alice can choose to take 0 stones on her first turn. Bob can then also take 0 stones, so the game ends with piles of sizes 3 and 6. Therefore, the score can be 3. It can be shown that Alice cannot achieve a larger score, and Bob cannot achieve a smaller score.
In the second test case, Alice can take all 10 stones from the third pile on her first turn. The game then ends with piles of sizes 13 and 6, so the score is 7.
在第一个测试用例中,Alice 可以选择在她的第一回合取走 0 颗石子。随后 Bob 也可以取走 0 颗石子,因此游戏结束时石堆的大小分别为 3 和 6。此时得分为 3。可以证明,Alice 无法获得更大的得分,且 Bob 也无法使得分更小。
在第二个测试用例中,Alice 可以在她的第一回合从第三堆中取走全部 10 颗石子。此后游戏结束,石堆的大小分别为 13 和 6,因此得分为 7。
输入解题思路,AI测评打分。不知道怎么写?