CF1603F October 18, 2017
foreverlasting · · 题解
题面:给出
做法:题意等价于
注意到原序列有序。
容易想到讨论
减去一个数是考虑基底不包含
而熟知
于是答案就是
这东西全部可以预处理出来,就做完了。即
其中
而证明
再两边同取
时间复杂度
{% fold code %}
//2021.12.5 by ljz
//email [email protected]
//if you find any bug in my code
//please tell me
const int N=1e7+10;
int pw[N],fac[N],inv[N],INV[N];
namespace MAIN{
int n,k,x;
int f[N];
inline void MAIN(){
n=read(),k=read(),x=read();
if(!x){
if(n>k){puts("0");return;}
res ret=1;
for(res i=0;i<n;i++)ret=mul(ret,Add(pw[k],kcz-pw[i]));
printf("%d\n",ret);
return;
}
f[0]=1;
res p=min(n,k),PW=qpow(2,n),inv2=qpow(2);
for(res i=1;i<=p;i++)f[i]=mul(f[i-1],mul(Add(PW,kcz-1),INV[i])),PW=mul(PW,inv2);
res A=1,ans=1;
for(res r=1;r<=p;r++)A=mul(A,Add(pw[k],kcz-pw[r])),add(ans,mul(A,f[r]));
printf("%d\n",ans);
}
}
{% endfold %}