zoukankan      html  css  js  c++  java
  • Codeforces Round #575 (Div. 3) A

    Codeforces Round #575 (Div. 3)

    A - 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 q independent queries.

    Let's see the following example: [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 4 candies, and Bob has 4 candies.

    Another example is [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 54 candies, and Alice takes 46 candies. Now Bob has 55 candies, and Alice has 56 candies, so she has to discard one candy — and after that, she has 55 candies too.

    Input

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

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

    Output

    Print q lines. The i-th line should contain the answer for the i-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

     

    思路:看样例猜题意系列,,答案显然为(a+b+c)/2。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 #include<cstring>
     5 #include<algorithm>
     6 #include<vector>
     7 #include<map>
     8 #include<set>
     9 #include<vector>
    10 #include<queue>
    11 using namespace std;
    12 #define ll long long
    13 const int mod=1e9+7;
    14 const int inf=1e9+7;
    15 
    16 //const int maxn=
    17  
    18 int main()
    19 {
    20     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    21      
    22     int T;
    23     cin>>T;
    24     ll int a,b,c;
    25     
    26     while(T--)
    27     {
    28         cin>>a>>b>>c;
    29         cout<<(a+b+c)/2<<endl;
    30         
    31     }
    32     return 0;
    33 }
    大佬见笑,,
  • 相关阅读:
    win_tc使用感受
    10进制转8进制(栈操作)
    动态栈
    数组
    单链表学习
    static用法
    基础2
    linux c first
    linux net command /uboot command
    opencv
  • 原文地址:https://www.cnblogs.com/xwl3109377858/p/11271597.html
Copyright © 2011-2022 走看看