constint N = 1e9; constint maxn = 1e7 + 10; unsignedint x = 123456789, y = 362436069, z, a[maxn]; int n, q; unsignedintgen() { unsignedint t; x ^= x << 16; x ^= x >> 5; x ^= x << 1; t = x; x = y; y = z; z = t ^ x ^ y; return z % N + 1; }
intmain() { scanf("%d%d%u", &n, &q, &z); for ( int i = 1; i <= n; ++ i ) a[i] = gen(); for ( int i = 1; i <= q; ++ i ) { int l = gen() % n + 1, r = gen() % n + 1; if ( l > r ) swap(l, r); // do your things ... } }
constint N = 1e9; constint maxn = 1e7 + 10; unsignedint x = 123456789, y = 362436069, z, a[maxn]; int n, q; int fa[maxn]; unsignedintgen() { unsignedint t; x ^= x << 16; x ^= x >> 5; x ^= x << 1; t = x; x = y; y = z; z = t ^ x ^ y; return z % N + 1; }