C++
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ull seed;
int next() {
seed = seed ^ (seed << 13);
seed = seed ^ (seed >> 7);
seed = seed ^ (seed << 17);
return (seed >> 33);
}
int main() {
int n, q;
cin >> n >> q >> seed;
for (int i = 0; i < 10000; i++) next();
vector<int> a(n);
for (int i = 0; i < n; i++) a[i] = next();
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;
return 0;
}
Java
import java.util.Scanner;
public class Main {
static long seed;
static int next() {
seed = seed ^ (seed << 13);
seed = seed ^ (seed >>> 7);
seed = seed ^ (seed << 17);
return (int)(seed >>> 33);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
seed = sc.nextLong();
for (int i = 0; i < 10000; i++) next();
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = next();
long 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 ^= (long)(cnt) * i;
}
System.out.println(sm);
}
}
D
import std.stdio, std.algorithm;
ulong seed;
int next() {
seed = seed ^ (seed << 13);
seed = seed ^ (seed >> 7);
seed = seed ^ (seed << 17);
return cast(int)(seed >> 33);
}
void main() {
int n, q;
readf("%d %d %d\n", &n, &q, &seed);
foreach (i; 0..10000) next();
int[] a = new int[n];
foreach (i; 0..n) a[i] = next();
long sm = 0;
foreach (i; 0..q) {
int x = next();
sm ^= long(a.count!(y => x > y)) * i;
}
writeln(sm);
}