[Yuhao Du Contest 7]Junk Problem
Difficulty Ratings
Idea Creativity: 4/5Techniques Used: 3/5
Implementation : 2/5
By xudyh
Statement
Given n≤1e7, find s distinct integers 1≤a1,a2,⋯,as≤n such that:-For all pairs (ai,aj) such that i<j, their XOR sum should be distinct.
-s≥⌊√0.5n⌋
Solution
So obviously we pick the minimum valid s. As s is O(√n), we would imagine splitting each integer into 2 parts, something like each integer is ui×2q+vi where 0≤ui,vi<2q, and all ui,vi is distinct. Then we just have to guarentee that if uw⊕ux=uy⊕uz then vw⊕vx≠vy⊕vz. ( ⊕ is xor)
Let q be the smallest integer such that 2q≥s. Consider we create a function f(x)=y that 0≤x,y<2q. Our final set will be i×2q+f(i) for all integers i in [0,s). It is easy to see that all integers generated is ≤N. So now we will focus on the function.
Imagine that we write all integers in binary and view it as a polynomial. E.g 5 -> 1012 -> x2+1. Then, imagine after any operation, coefficents are adjusted modulo 2. E.g 5+3=(x2+1)+(x+1)=x2+x+2=x2+x=6. You realise that addition suddenly became bitwise xor! Lets also add an additional rule: the resulting polynomial is done under modulo P(x), where P(x) is an special(?) polynomial of degree q. Eg: q=3,P(x)=x3+x+1, 5×7=(x2+1)(x2+x+1)=(x4+x3+x2+x2+x+1)=x2+x=6. So now we also invented multiplication. These rules are called arithmetic under the field F2q. So the requirements of such P(x) is that its irreducible under this field, because we will need to use bezout's theorem on it. Irredicible = not factorizable.
So now addition and multiplication is defined like the new rules, i want that if w,x,y,z distinct and w+x=y+z then f(w)+f(x)≠f(y)+f(z). Let t=w+x. That means we want f(x)+f(t+x)=C to have two roots of x (note that t+x=t−x since the coefficents are modulo 2). So we want f(x)+f(t+x)−c=0 to be a quadratic equation. By the selection of P(x) we guarenteed that under new rules, quadratic equation still only has two roots. Ultimately, we realize that if we let f(x)=x3+k, f(x)+f(t+x)−c=x3+t3+t2x+tx2+x3−c=(t)x2+(t2)x+(t3+c). As w≠x, t≠0 and the equation would become quadratic.
Last thing is that as the elements have to be positive, f(0) cannot be 0 so we should let f(x)=x3+1 or just with any other constant term that is not 0.
留言
張貼留言