首页 > 其他分享 >CF1770F Koxia and Sequence

CF1770F Koxia and Sequence

时间:2023-07-20 17:35:47浏览次数:31  
标签:dbinom limits Sequence sum bigoplus Koxia mod subseteq CF1770F

题意

给定非负整数 \(n,x,y\),对于所有满足 \(\sum\limits_{i=1}^{n}a_i=x\) 并且 \(\text{OR}_{i=1}^{n}a_i=y\) 的 \(\{a_n\}\),求 \(\bigoplus\limits_{i=1}^{n}a_i\) 的异或和。

\(n\le 2^{40},x\le 2^{60},y\le 2^{20}\)。

题解

首先根据对称性,当 \(n\) 为偶数时,答案为 \(0\)。所以只考虑 \(n\) 为奇数的情况,为 \(a_1\) 的异或和。

拆位,对每一位 \(t\),计算 \(a_1\) 的第 \(t\) 位为 \(1\) 的方案数 \(\text{mod}\ 2\) 的结果。此时显然 \(\bigoplus\limits_{i=1}^{n}a_i\) 第 \(t\) 位为 \(1\)。

考虑容斥,设 \(g(y)\) 为按位或为 \(y\) 的方案数,\(f(y)\) 为按位或为 \(y\) 的子集的方案数,显然 \(f(y)=\sum\limits_{y'\subseteq y}g(y')\),反演结论得到 \(g(y)=\sum\limits_{y'\subseteq y}(-1)^{|y|-|y'|}f(y')\),前提是 \(y'\) 第 \(t\) 位为 \(1\)。

由于我们只需要得到 \(g(y)\) 的奇偶性,所以我们可以将式子变为 \(g(y)\equiv\bigoplus\limits_{y'\subseteq y}f(y')\mod 2\)。

因为钦定 \(a_1\) 的第 \(t\) 位为 \(1\),我们可以让 \(a_1\) 减去 \(2^t\),此时 \(\sum\limits_{i=1}^{n}a_i=x-2^t\)。 由 \(\text{Lucas}\) 定理推论(组合数奇偶性定理)与 \(\text{Vandermonde}\) 卷积公式得:

\[\begin{aligned}f(y)&=\sum\limits_{\sum\limits a_i=x-2^t}[a_1\subseteq y-2^t][a_2\subseteq y][a_3\subseteq y]...[a_n\subseteq y]\\&\equiv\sum\limits_{\sum a_i=x-2^t}\dbinom{y-2^t}{a_1}\dbinom{y}{a_2}\dbinom{y}{a_3}...\dbinom{y}{a_n}\mod 2\\&\equiv\dbinom{ny-2^t}{x-2^t}\mod 2\\&\equiv [x-2^t\subseteq ny-2^t]\mod 2\end{aligned} \]

所以答案即为:

\[\begin{aligned}\sum\limits_{t}2^tf(y)&=\sum\limits_t 2^t\bigoplus\limits_{y'\subseteq y,2^t\in y'}g(y')\\&=\sum\limits_t 2^t\bigoplus\limits_{y'\subseteq y,2^t\in y'}[x-2^t\subseteq ny'-2^t]\end{aligned} \]

\(O(y\log y)\) 枚举 \(t,y'\) 即可。

提交记录。

标签:dbinom,limits,Sequence,sum,bigoplus,Koxia,mod,subseteq,CF1770F
From: https://www.cnblogs.com/Ender32k/p/17569006.html

相关文章

  • [LeetCode] 2486. Append Characters to String to Make Subsequence
    Youaregiventwostrings s and t consistingofonlylowercaseEnglishletters.Return theminimumnumberofcharactersthatneedtobeappendedtotheendof s sothat t becomesa subsequence of s.A subsequence isastringthatcanbederived......
  • hdu 2227 Find the nondecreasing subsequences (树状数组+dp+离散化)
    题意:给定一个长度为n(n<=100000)的整数序列,求其中的递增序列的个数。对于某些序列中的递增序列的个数是可以用dp来求解的,其状态转移方程为:dp[i]=sum(dp[j])+1,j<i&&a[j]<a[i]根据状态转移方程可以得知这样dp的时间复杂度为O(n^2),而对于题目给定的10^6的数量级来说,这样......
  • p_sequencer的使用
    为什么要有p_sequencer?sequence是从uvm_object拓展而来,所以不能访问uvm_component组成的uvm层次结构的,不能通过组件层次调用访问成员变量(如,在env中访问driver的成员变量htrans,可以通过m_env.m_agt.m_drv.htrans来访问)。那sequence如何访问uvm_component的成员变量呢?通过媒介:se......
  • PAT-甲级-1007 Maximum Subsequence Sum C++
    Givenasequenceof K integers{ N1​, N2​,..., N​K }.Acontinuoussubsequenceisdefinedtobe{ Ni​, Ni+1​,..., Nj​ }where 1≤i≤j≤K.TheMaximumSubsequenceisthecontinuoussubsequencewhichhasthelargestsumofitselements.Fore......
  • [LeetCode] 2542. Maximum Subsequence Score
    Youaregiventwo 0-indexed integerarrays nums1 and nums2 ofequallength n andapositiveinteger k.Youmustchoosea subsequence ofindicesfrom nums1 oflength k.Forchosenindices i0, i1,..., ik-1,your score isdefinedas:Thes......
  • [ABC134E] Sequence Decomposing
    SequenceDecomposingの传送门前置知识multisetDescription求一个数列\(a\)中递增子序列的最少个数。Solution考虑用multiset存每个递增子序列的最后一个数。对于每一个\(a_i\)(\(1\lei\len\)),二分查找multiset中第一个小于\(a_i\)的数。如果有,就删除这......
  • CF407E k-d-sequence
    Description我们称一个数列为一个好的\(k-d\)数列,当且仅当我们在其中加上最多\(k\)个数之后,数列排序后为一个公差为\(d\)的等差数列。你手上有一个由\(n\)个整数组成的数列\(a\)。你的任务是找到它的最长连续子串,使得满足子串为好的\(k-d\)数列。Solution如果一段......
  • [CF407E] k-d-sequence
    [CF407E]k-d-sequence复健不会写代码。首先找充要条件,如一个子串\(a_l,a_{l+1}...a_r\)合法,则首先这些数互不重复,其次这些数对\(d\)取模相同,最重要的是\[\dfrac{\max{a}-\min{a}}{d}-(r-l)\lek\]左边表示最终形成的等差数列中的数的个数,\(r-l\)表示已经存在的......
  • 首次使用Charles,Structure和Sequence中没有内容,Recording中有内容的解决方法
    1.首次使用Charles记录下载打开软件后,SSLProxying已经配置好了,但是Structure和Sequence中没有内容,而Recording中有内容解决办法:RecordingSettings中Exclude中Remove就可以了点击Proxy,点击RecordingSettings需要查看的内容可以在Include中添加......
  • 【CF1621G】Weighted Increasing Subsequences 题解(优化树状数组)
    CF传送门|LG传送门。优化树状数组+反向处理。Solution发现直接做不好下手。难点主要在求出所有的上升子序列并计算它们分别的贡献。所以需要反向考虑每个单点在什么情况下产生贡献。一个单点会产生多少贡献。一个单点产生贡献的条件很容易得到。一个是在一个上升子序......