#P6851. 「Pinely Round 1」进位(加强版)

    ID: 1809 Type: RemoteJudge 1000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>子任务数学多项式 / 形式幂级数DFT(含 NTT)及FFTDP组合计数数位 DP生成函数 / 母函数Codeforces2022

「Pinely Round 1」进位(加强版)

题目描述

原题链接:Codeforces 1761D - Carry Bit。原出题人 unputdownable\tt{\color{black}{u}}{\color{red}{ nputdownable}},经其同意后加强并上传 loj。

注意,不仅修改了数据范围,题意也有改动。

设一个数 vv 的二进制表示中 11 的个数为 g(v)g(v)

f(x,y)=g(x)+g(y)g(x+y)f(x,y)=g(x)+g(y)-g(x+y),也即 xxyy 二进制相加时的进位数

现给定 N,k(kN)N,k(k\le N),你要对所有 n=k,k+1,,Nn=k,k+1,\cdots,N,求出

S(n,k)=i=02n1j=02n1[f(i,j)=k]S(n,k)=\sum_{i=0}^{2^n-1}\sum_{j=0}^{2^n-1}[f(i,j)=k]

答案对 109+710^9+7 取模。

输入格式

一行两个整数,NNkk

输出格式

为了避免输出量过大,我们采用如下方式输出。

fn=S(n,k)mod1000000007f_n=S(n,k)\bmod 1000000007

gn=nfng_n=nf_n,且不取模(C++ 选手可使用 unsigned long long 类型计算并存储)。

你应当输出 gkgk+1gk+2gNg_k\oplus g_{k+1}\oplus g_{k+2}\oplus\cdots\oplus g_N,其中 \oplus 表示按位异或运算。

Sample Input 1

3 1

Sample Output 1

36

Sample Input 2

3 0

Sample Output 2

64

Sample Input 3

998 244

Sample Output 3

630338983045

Sample Input 4

65537 65530

Sample Output 4

13776173599910

Sample Input 5

926878 926871

Sample Output 5

1105232236403512

Sample Input 6

1919810 114514

Sample Output 6

1431279937541241

数据范围与提示

对于 100%100\% 的数据,0kN2×1070\le k\le N\le2\times10^7

以下记 r=Nkr=N-k

子任务编号 子任务分值 NN kk 特殊性质 子任务依赖
11 2pts2{\rm pts} 5\le5 r=0r=0
22 3pts3{\rm pts} 11
33 5pts5{\rm pts} 500\le500 r=0r=0
44 9pts9{\rm pts} 2,32,3
55 5pts5{\rm pts} 2000\le2000 r=0r=0 33
66 13pts13{\rm pts} 4,54,5
77 5pts5{\rm pts} 100000\le100000 r=0r=0 55
88 5pts5{\rm pts} r10r\le10 77
99 7pts7{\rm pts} 6,86,8
1010 8pts8{\rm pts} 1000000\le1000000 r=0r=0 77
1111 8pts8{\rm pts} r10r\le10 8,108,10
1212 10pts10{\rm pts} 9,119,11
1313 5pts5{\rm pts} 20000000\le20000000 r=0r=0 1010
1414 15pts15{\rm pts} 12,1312,13