#include #include #include #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using ull = unsigned long long; // https://gist.github.com/yosupo06/f8b62b4d070275d9814ecaf45519f720 // g++-5 -W -std=c++14 0670.cpp ull seed; int next() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); } void TLE2(int n, int q, vector a) { ll sm = 0; sort(all(a)); for (int i = 0; i < q; i++) { int x = next(); int cnt = lower_bound(all(a), x) - a.begin(); sm ^= ll(cnt) * i; } cout << sm << endl; } void TLE(int n, int q, vector a) { ll sm = 0; for (int i = 0; i < q; i++) { int x = next(); int cnt = 0; for (int j = 0; j < n; j++) { if (a[j] < x) cnt++; } sm ^= ll(cnt) * i; } cout << sm << endl; } int main() { int n, q; cin >> n >> q >> seed; for (int i = 0; i < 10000; i++) next(); vector a(n); for (int i = 0; i < n; i++) a[i] = next(); TLE2(n, q, a); // TLE(n, q, a); return 0; }