Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) F. Bits And Pieces(DP)

题目链接:https://codeforces.com/contest/1208/problem/F

 

神奇的SOSdp?感觉就是数位dp啊

https://codeforces.com/blog/entry/45223

hint:这个题要把dp的顺序反一下

 

代码:

#include
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair pii;
const int MAXN=1e6+5;
int dp[(1<<21)+1][22],a[MAXN];
void dfs(int num,int k)
{
	if(k>20) return ;
	if(dp[num][k]>1) return ;
	dp[num][k]++;
	dfs(num,k+1);
	if((num>>k)&1)
		dfs(num^(1<=1;i--)
	{
		int res=0;
		int t=0;
		for(int j=20;j>=0;j--)
		{
			if((a[i]>>j)&1) res|=1<1)
				res|=1<

 

你可能感兴趣的:(codeforces)