hiho week 295 register

Ended

Participants:48

Verdict:Accepted
Score:100 / 100
Submitted:2020-02-28 00:15:40

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mod = 1e9+7;
long quick_power(long a, long b) {
    long ans = 1;
    while (b) {
        if (b & 1)
            ans = (ans * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }
    return ans;
}
long large_n_power(int n) {
    return quick_power(2, n % (mod-1));
}
int SetCounting(vector<int>& arr, int K) {
    int n = arr.size();
    sort(arr.begin(), arr.end());
    long res = 0;
    for (int i = 0; i < n; ++i) {
        int k = lower_bound(arr.begin(), arr.end(), K - arr[i]) - arr.begin();
        k -= (k==n);
        if (k >= i) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX