CodeForces 1332D - Walk on Matrix [construction]

Meaning of the questions:

A matrix structure, so that from the top left to the bottom right corner of the actual maximum ratio provided the title \ (DP \) method Big \ (K \) .

analysis:

Such that \ (DP \) maximum value is determined \ (0 \) , for the practical maximum \ (K \) .
For the matrix:

\[ \left[ \begin{matrix} a_{1,1} & a_{1,2} \\ a_{2,1} & a_{2,2} \end{matrix} \right] \]

According to the title of \ (DP \) approach,
\ (A_} = max {2,2 & \ A_ {1,1} {\ & A_ {1,2} \} & 2,2 & A_ {\, \ A_. 1 { , 1} \ & a_ {2,1
} \ & a_ {2,2} \} \) matrix is constructed:

\[ \left[ \begin{matrix} x \bigoplus k & x \\ k & x \bigoplus k \end{matrix} \right] \]

There are: \ (A_ {2,2 &} = max \ {(X \ bigoplus K) \ & X, (X \ bigoplus K) \ & K \} \)
and also because there are: \ ((X \ bigoplus K) \ & X \ & k = 0 \)
be modified on the basis of the original matrix:

\[ \left[ \begin{matrix} x \bigoplus k & x & 0\\ k & x \bigoplus k & k \end{matrix} \right] \]

So we want the \ ((the X-\ bigoplus k) \ & the X-> (the X-\ bigoplus k) \ & k \) , in order to ensure press (dp \) \ The results obtained to practice \ (0 \) .
So \ (x \) values is very critical. \ (X \) should be taken than \ (k_ {max} \) is large and is \ (2 \) is an integer power, such as \ (2 ^ {17} \) .
So \ (DP \) maximum value is acquired \ ((x \ bigoplus k)
\ & x \ & k = 0 \) practical maximum of \ ((X ^ K) \ & K = K \) .
The final matrix is:

\[ \left[ \begin{matrix} 2^{17} \bigoplus k & 2^{17} & 0\\ k & 2^{17} \bigoplus k & k \end{matrix} \right] \]

Code:

C++:

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    scanf("%d",&k);
    printf("2 3\n");
    int x=1<<17;
    printf("%d %d %d\n",x^k,x,0);
    printf("%d %d %d\n",k,x^k,k);
    return 0;
}

python:

k=int(input())
print("2 3\n")
x=1<<17
print(x^k,x,0)
print(k,x^k,k)

Guess you like

Origin www.cnblogs.com/1024-xzx/p/12637820.html