# bzoj4069【APIO2015】巴厘岛的雕塑

## 4069: [Apio2015]巴厘岛的雕塑

Time Limit: 10 Sec  Memory Limit: 64 MB
Submit: 192  Solved: 89
[Submit][Status][Discuss]

## Description

P 与 Q 按位取或后的结果是： (pM−1  OR  qM−1)(pM−2 OR qM−2)…(p1 OR q1)(p0 OR q0)。

0 OR 0=0
0 OR 1=1
1 OR 0=1
1 OR 1=1

6 1 3
8 1 2 1 5 4

11

explanation

## HINT

子任务 1 （9 分）

1< = N< = 20

1< = A< = B< = N

0< = Yi< = 1000000000

1< = N< = 50

1< = A< = B< = min{20,N}

0< = Yi< = 10

1< = N< = 100

A=1

1< = B< = N

0< = Yi< = 20

1< = N< = 100

1< = A< = B< = N

0< = Yi< = 1000000000

1< = N< = 2000

A=1

1< = B< = N

0< = Yi< = 1000000000

#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define F(i,j,n) for(int i=j;i<=n;i++)
#define D(i,j,n) for(int i=j;i>=n;i--)
#define ll long long
#define maxn 2005
#define inf 1000000000
using namespace std;
int n,a,b,len,g[maxn];
ll ans,sum[maxn];
bool f[maxn][maxn];
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
inline void solve1()
{
D(pos,len,1)
{
memset(f,false,sizeof(f));
f[0][0]=true;
F(i,1,n) F(j,1,i) F(k,j-1,i-1) if (f[k][j-1])
{
ll tmp=sum[i]-sum[k];
if (((tmp>>pos)|ans)==ans&&(tmp&(1ll<<(pos-1)))==0){f[i][j]=true;break;}
}
bool flag=false;
F(i,a,b) if (f[n][i]){flag=true;break;}
ans<<=1;
if (!flag) ans|=1;
}
}
inline void solve2()
{
D(pos,len,1)
{
F(i,1,n) g[i]=inf;
F(i,1,n) F(j,0,i-1)
{
ll tmp=sum[i]-sum[j];
if (((tmp>>pos)|ans)==ans&&(tmp&(1ll<<(pos-1)))==0) g[i]=min(g[i],g[j]+1);
}
ans<<=1;
if (g[n]>b) ans|=1;
}
}
int main()
{