杂题

题意

给定(16n)个数,对于其的一个置换,令(x=(a_1oplus a_2)otimes(a_3oplus a_4)otimes cdots otimes (a_{8n-1}oplus a_{8n}))(y=(a_{8n+1}oplus a_{8n+2})otimes (a_{8n+3}oplus a_{8n+4})otimes cdots otimes(a_{16n-1}oplus a_{16n}))(x-y)最大是多少。
(nle 10^4,a_ile 10^{9})

做法

引理(nge 2)时,对于任意(8n)个数字,一定存在置换方案使得(y=0)

证明:
(f(n))表示对于(8n)个数,不考虑具体数值,有多少种本质不同的排列方案,显然(f(n)=frac{(8n)!}{2^{4n}(4n)!})
(g(n))为结果(>0)的方案。
(g_i(n))为第(i)位为(1)的方案数,如果方案数不为(0)的话,那么恰好有(4n)个数第(i)为为(1),则方案数为((4n)!),故(g_i(n)le (4n)!)
(g(n)le sumlimits_{i=0}^{30}g_i(n)le 30dot (4n)!)
(nge 2)时,有(f(n)>g(n))

因此我们仅需选择(8n)个数字,并排列,最大化(x)

可以按位贪心,每次确定一些位集合,两个位集合互补的数字可以放到一个括号中。

原文地址:https://www.cnblogs.com/Grice/p/14781014.html