题目传送门
最近在学习数位dp,具体姿势可以参照这篇论文:
#include#include #include using namespace std;const int maxn = 40;int f[maxn][maxn];int X,Y,K,B;void init() { memset(f,0,sizeof(f)); f[0][0] = 1; for(int i = 1;i <= 31;++i) { f[i][0] = f[i-1][0]; for(int j = 1;j <= i;++j) f[i][j] = f[i-1][j] + f[i-1][j-1]; }}int calc(int x,int k) { int tot = 0,ans = 0; for(int i = 31;i > 0;--i) { if(x&(1< k) break; x = x ^(1< 0) { d[m++] = n % b; n /= b; } for(i = m-1;i >= 0;--i) { if(d[i] > 1) { for(j = i;j >= 0;--j) ret |= (1<