Walk on Matrix
Subject to the effect that:
To give you a positive integer k, let you design a n * m board, each board has a point value, you just start at (1,1) point, your goal is to come (n, m) point, and to obtain a maximum priority value, the weight value calculation formula as dp [i] [j] = max (dp [i-1] [j] & a [i] [j], dp [i] [j-1] & a [i] [j]);
Dp clear that this applies only to conventional operation, bit operation is not applicable;
So you entitled to k, let you design chessboard, so that the maximum value of the dp operation, with the difference between the actual maximum value of k;
Others looked at the code and found that only 3 lines;
Thinking this problem is to construct dp out value is 0, the actual value of k, this comparison really want, the basic idea of the structure;
But how construction is more difficult, and there is no good explanation;
On the four formulas:
k&k=k,x&k=0,(x+k)&k=k,(x+k)&x=x;
Directly on the code:
#include<bits/stdc++.h>
#define LL long long
#define pa pair<int,int>
#define ls k<<1
#define rs k<<1|1
#define inf 0x3f3f3f3f
using namespace std;
const int N=510;
const int M=1010;
const LL mod=1e8-3;
int main(){
int k;
cin>>k;
int x=(1<<17);
cout<<2<<" "<<3<<endl;
cout<<x+k<<" "<<x<<" "<<0<<endl;
cout<<k<<" "<<x+k<<" "<<k<<endl;
return 0;
}