Three Piles of Candies

Three Piles of Candies

Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob takes one of the other two piles. The last pile is split between Alice and Bob as they want: for example, it is possible that Alice takes the whole pile, and Bob gets nothing from it.

After taking the candies from the piles, if Alice has more candies than Bob, she discards some candies so that the number of candies she has is equal to the number of candies Bob has. Of course, Bob does the same if he has more candies.

Alice and Bob want to have as many candies as possible, and they plan the process of dividing candies accordingly. Please calculate the maximum number of candies Alice can have after this division process (of course, Bob will have the same number of candies).

You have to answer qq independent queries.

Let's see the following example: [1,3,4][1,3,4]. Then Alice can choose the third pile, Bob can take the second pile, and then the only candy from the first pile goes to Bob — then Alice has 44 candies, and Bob has 44 candies.

Another example is [1,10,100][1,10,100]. Then Alice can choose the second pile, Bob can choose the first pile, and candies from the third pile can be divided in such a way that Bob takes 5454 candies, and Alice takes 4646 candies. Now Bob has 5555 candies, and Alice has 5656 candies, so she has to discard one candy — and after that, she has 5555 candies too.

Input

The first line of the input contains one integer qq (1≤q≤10001≤q≤1000) — the number of queries. Then qq queries follow.

The only line of the query contains three integers a,ba,b and cc (1≤a,b,c≤10161≤a,b,c≤1016) — the number of candies in the first, second and third piles correspondingly.

Output

Print qq lines. The ii-th line should contain the answer for the ii-th query — the maximum number of candies Alice can have after the division, if both Alice and Bob act optimally (of course, Bob will have the same number of candies).

Example

Input

4
1 3 4
1 10 100
10000000000000000 10000000000000000 10000000000000000
23 34 45

Output

4
55
15000000000000000
51

均分给两人即可

#include<bits/stdc++.h>

using namespace std;
int main()
{
	int n;
	cin >> n;
	while(n --){
		long long a;
		long long sum = 0;
		for(int i = 0;i < 3;i ++){
			cin >> a;
			sum += a;
		}
		cout << sum/2 << endl;
	}
	return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值