CF2254A.Riptide
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Alice, Bob, and Charlie are playing a game with tokens. They start with a, b, and c tokens, respectively.
The game is played in rounds. Before the beginning of each round, they check the number of tokens everyone has:
- If any two players have the exact same number of tokens, the game immediately ends.
- Otherwise, the round begins, all three players have a strictly different number of tokens. The player with the strictly most tokens gives exactly 1 token to the player with the strictly fewest tokens.
Given the starting tokens a, b, and c, determine exactly how many rounds the game will last before it ends.
爱丽丝、鲍勃和查理正在用筹码进行一场游戏。他们初始分别拥有 a、b 和 c 个筹码。
游戏以轮次进行。在每轮开始前,他们检查各自当前拥有的筹码数量:
- 若任意两名玩家拥有的筹码数恰好相等,则游戏立即结束;
- 否则,本轮开始——此时三名玩家的筹码数严格互不相同。持有最多筹码的玩家向持有最少筹码的玩家恰好给予 1 个筹码。
给定初始筹码数 a、b 和 c,请精确计算游戏在结束前共进行多少轮。
输入格式
The first line contains a single integer t (1≤t≤103) — the number of test cases.
Each test case consists of a single line containing three integers a, b, and c (1≤a,b,c≤10).
第一行包含一个整数 t(1≤t≤103)——测试用例的数量。
每个测试用例由一行组成,包含三个整数 a、b 和 c(1≤a,b,c≤10)。
输出格式
For each test case, output a single integer — the number of rounds the game will last before it ends.
对于每个测试用例,输出一个整数——游戏结束前将持续的轮数。
输入输出样例
输入#1
6 1 2 3 4 6 1 3 3 7 1 7 10 6 1 9 1 1 1
输出#1
1 2 0 3 3 0
说明/提示
In the first test case:
- No two players have the same number of tokens.
- Charlie has the most tokens (3 tokens), and Alice has the fewest tokens (1 token). Therefore, Charlie gives Alice a token.
- Now, Alice has 2 tokens, Bob has 2 tokens, and Charlie has 2 tokens. Since there are two players (or more) with the same number of tokens, the game ends.
The game ended after 1 round, so the answer is 1.
In the second test case, the game is played as follows:
- Bob gives Charlie a token, now Alice has 4 tokens, Bob has 5 tokens, and Charlie has 2 tokens.
- Bob gives Charlie a token, now Alice has 4 tokens, Bob has 4 tokens, and Charlie has 3 tokens. Since two players have the same number of tokens, the game ends.
The game lasted 2 rounds.
In the third test case, two players already have the same number of tokens. So the answer is 0 since no rounds were played.
在第一个测试用例中:
- 没有任意两名玩家拥有相同数量的代币。
- 查理拥有的代币最多(3 个代币),而爱丽丝拥有的代币最少(1 个代币)。因此,查理给爱丽丝一个代币。
- 此时,爱丽丝有 2 个代币,鲍勃有 2 个代币,查理也有 2 个代币。由于存在两名(或更多)玩家拥有相同数量的代币,游戏结束。
游戏在 1 轮后结束,因此答案为 1。
在第二个测试用例中,游戏过程如下:
- 鲍勃给查理一个代币,此时爱丽丝有 4 个代币,鲍勃有 5 个代币,查理有 2 个代币。
- 鲍勃再次给查理一个代币,此时爱丽丝有 4 个代币,鲍勃有 4 个代币,查理有 3 个代币。由于有两名玩家拥有相同数量的代币,游戏结束。
游戏共持续了 2 轮。
在第三个测试用例中,已有两名玩家拥有相同数量的代币。因此答案为 0,因为未进行任何轮次。
输入解题思路,AI测评打分。不知道怎么写?