// yukicoder: No.670 log は定数 // 2019.5.17 bal4u #include #include typedef long long ll; typedef unsigned long long ull; ull seed; int xorshift() { seed = seed ^ (seed << 13); seed = seed ^ (seed >> 7); seed = seed ^ (seed << 17); return (seed >> 33); } #define MAX (1<<19) // 2^19 #define SFT 12 // 2^12 int f[MAX+3][10], s[MAX+3]; char w[MAX+3]; int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { int i, j, a, c, k, N, Q; ll ans; scanf("%d%d%lld", &N, &Q, &seed); i = 10000; while (i--) xorshift(); // gomi i = N; while (i--) { a = xorshift(), k = a >> SFT; f[k][w[k]++] = a; } for (i = 0; i < MAX; i++) { s[i+1] = s[i]+w[i]; if (w[i] > 1) qsort(f[i], w[i], sizeof(int), cmp); } ans = 0; for (i = 0; i < Q; i++) { a = xorshift(), k = a >> SFT; c = s[k]; for (j = 0; j < w[k]; j++) { if (f[k][j] >= a) break; c++; } ans ^= i * (ll)c; } printf("%lld\n", ans); return 0; }