Codeforces Round #575 div3

比赛网址:

http://codeforces.com/contest/1196

Example

Input

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

4
55
15000000000000000
51

    #include<bits/stdc++.h>
    typedef long long ll;
    using namespace std;
    int main () {
        int n;
        cin >> n;
        ll a, b, c;
        while(n--) {
            cin >> a >> b >> c;
            cout << (a + b + c) / 2 << endl;
        }
    }

 Example

Input

3
5 3
7 18 3 14 1
5 4
1 2 3 4 5
6 2
1 2 8 4 10 2
Output

YES
1 3 5
NO
NO

    #include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    int main() {
        ll t;
        cin>>t;
        while(t--) {
            ll n, k, j;
            cin >> n >> k;
            vector<int> v;
            for(int i = 0; i < n; i++) {
                cin >> j;
                if(j & 1)
                    v.push_back(i + 1);
            }
            if(v.size() < k || (v.size() % 2 != k % 2)) {   //若奇数的个数少于k的个数 或者 奇数的个数与k的奇偶性不同
                cout<<"NO"<<endl;
                continue;
            }
            cout<<"YES"<<endl;
            for(int i = 0; i < k - 1; i++)
                cout << v[i] << " ";
            cout << n << endl;
        }
    }

 

posted @ 2019-07-25 20:10  LightAc  阅读(189)  评论(0编辑  收藏  举报
返回顶端