一步都没想到,一定是状态不好吧,一定吧一定吧?

加训数数!

题意

给定 \(n, x, y\),定义好的序列 \(\{a_i\}_{i = 1}^n\) 满足 \(\sum\limits_{i = 1}^na_i = x, \operatorname{OR}\limits_{i = 1}^na_i = y\)。求所有好的序列的异或和的异或和。

数据范围:\(1 \le n \le 2^40, 0 \le x < 2^60, 0 \le y < 2^20\)。

题解

异或和,大力抵消!根据对称性,每个位置对答案的贡献是一样的,所以 \(2|n\) 答案为 \(0\),否则只需要统计第一个位置的贡献。

\(\operatorname{OR}\) 和的限制传统方法就是容斥。那么设 \(f(y)\) 表示答案,\(g(y') = \bigoplus\limits_{t \subseteq y'}f(t)\),则 \(f(y) = \bigoplus\limits_{y' \subseteq y}g(y')\)。于是只要算 \(g\)。

接下来,考虑拆开位。令 \(a_1\) 的某一位 \(k\) 为 \(1\) 以后,\(\operatorname{OR}\) 和的限制形如 \(a_1 \subseteq y' - 2^k, a_{2 \dots n} \subseteq y'\);同时还有 \(\sum a_i = x - 2^k\)。怎么做呢?这边有个逆天的东西 \(p \subseteq q \iff \dbinom{q}{p} \equiv 1 \pmod 2\)。然后这两个限制直接变成了范德蒙德卷积,该位贡献为 \(1\) 当且仅当 \(\dbinom{ny' - 2^k}{x - 2^k} \equiv 1 \pmod 2\)。也就是 \(x - 2^k \subseteq ny' - 2^k\)。

做完了。很喜欢 OIer 的一句话:啊?

CF1770F Koxia and Sequence的更多相关文章

  1. oracle SEQUENCE 创建, 修改,删除

    oracle创建序列化: CREATE SEQUENCE seq_itv_collection            INCREMENT BY 1  -- 每次加几个              STA ...

  2. Oracle数据库自动备份SQL文本:Procedure存储过程,View视图,Function函数,Trigger触发器,Sequence序列号等

    功能:备份存储过程,视图,函数触发器,Sequence序列号等准备工作:--1.创建文件夹 :'E:/OracleBackUp/ProcBack';--文本存放的路径--2.执行:create or ...

  3. DG gap sequence修复一例

    环境:Oracle 11.2.0.4 DG 故障现象: 客户在备库告警日志中发现GAP sequence提示信息: Mon Nov 21 09:53:29 2016 Media Recovery Wa ...

  4. Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  5. [LeetCode] Sequence Reconstruction 序列重建

    Check whether the original sequence org can be uniquely reconstructed from the sequences in seqs. Th ...

  6. [LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列

    Given a binary tree, find the length of the longest consecutive sequence path. The path refers to an ...

  7. [LeetCode] Verify Preorder Sequence in Binary Search Tree 验证二叉搜索树的先序序列

    Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary ...

  8. [LeetCode] Longest Consecutive Sequence 求最长连续序列

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  9. [LeetCode] Permutation Sequence 序列排序

    The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  10. Leetcode 60. Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

随机推荐

  1. scoket用法

    一.scoket基本介绍 1.scoket简介(以下是来自chatgpt回答) 1)Socket(套接字)是计算机网络中用于描述主机之间通信的一种机制.它定义了一种标准的接口, 使得应用程序可以利用网 ...

  2. day03-搭建微服务基础环境02

    搭建微服务基础环境02 3.创建使用会员微服务模块-service consumer 3.1需求分析 浏览器向service consumer请求某个数据,service consumer会去向ser ...

  3. 关于关键字final用法以及意义

    *   * 1.final可以用来修饰的结构:类.方法.变量  *   * 2.final用来修饰一个类:此类不能被其他类所继承.  *           比如:String类.System类.St ...

  4. [大数据]Hadoop HDFS文件系统命令集

    基本格式: hadoop fs -cmd [args] 1 Query 显示命令的帮助信息 # hadoop fs -help [cmd] 查看hadoop/hdfs的用户 # hdfs dfs -l ...

  5. 详解C++中的extern与static关键字

    本章通过问答方式明晰两个关键字及其作用. Q1:对于int x:,不加extern关键字他就是个未赋初值的定义,但是如果加了static或者extern都可以表示这仅是一个声明吗? A:不是的,具体情 ...

  6. AI测试101:测试AI系统的实用技巧&ML和AI自动化工具

    基于人工智能的系统,也称为神经网络(NN Neural Networks),和其他应用程序一样是 "系统",因此需要测试.本文将指导你测试AI和基于NN的系统,并理解相关概念. 测 ...

  7. 在void 中使用return的意思

    在定义的void函数里如果想要提前终止函数 格式为 return; 如果 在有返回值的函数中 格式为: return+值(0 -1 ......) 但如果在void 函数中写return 0 ; 则会 ...

  8. C# 闭包类对弱引用的坑

    闭包.弱引用的简单概念,大佬们描述的很多,有不了解的可以看看: 理解C#中的闭包 - 黑洞视界 - 博客园 (cnblogs.com) C#弱引用(WeakReference) - 简书 (jians ...

  9. Java中数字相关的类有哪些?Nuber数字类和Math数学类详解

    前言 我们在解决实际问题时,会经常对数字.日期和系统设置进行处理,比如在我们的代码中,经常会遇到一些数字&数学问题.随机数问题.日期问题和系统设置问题等. 为了解决这些问题,Java给我们提供 ...

  10. 深入理解 python 虚拟机:描述器的王炸应用-property、staticmethod 和 classmehtod

    深入理解 python 虚拟机:描述器的王炸应用-property.staticmethod 和 classmehtod 在本篇文章当中主要给大家介绍描述器在 python 语言当中有哪些应用,主要介 ...