Daily look at the title series 1

CF2B The least round way

Topic link: https: //www.luogu.org/problem/CF2B

Title Description

Given a non-negative integers n-NN × \ Times n- n- × n-square matrix, you need to find a path:

The upper left corner as a starting point

You can only go to the right or down

To the lower right corner as the end point and, if the number we encountered along the way are multiplied, the product should be minimal "round", in other words, should be a minimum number of 0's end.

Input Format

The first row contains an integer n ( 2≤n≤10002 Leq \ Leq 1000 \ n 2 n . 1 0 0 element 0), n is the size of the matrix, the matrix comprising n rows next to (not more than 10 ^ 9 the non-negative integer).

Output Format

The first line should contain the minimal number of tail 0, the corresponding second line printing path (Annotation: D for the next, R is the Right)

3
1 2 3
4 5 6
7 8 9

Requires the minimum number of 10 come 0,0, 10 come from the 2 * 5, the number of each of the matrix 2 and 5 do quality factorization, the matrix on the path taken to be formed of a minimum number of 2 to 5 and {2,5}

 


 

CF3B Lorry

https://www.luogu.org/problem/CF3B

Translation of the meaning of problems

Translation of the meaning of problems

There is a load v wagon, ready to ship two goods. A weight of the article 1, the weight of the object B is 2, each item has a value. The maximum value can seek trucks transported goods.

Input Format

The first line contains two integers n and v, respectively, there are n items, for truck load v. (1 ≤ n ≤ 10 ^ 5; 1 ≤ v ≤ 10 ^ 9)

Next n lines of two integers, respectively, and the weight value of pi ti article. , (1 ≤ ti ≤ 2; 1 ≤ pi ≤ 10000)

Output Format

The first line, an integer representing the maximum value.

Weight of the items pose the greatest value in the second row of (if not the only answer any of your output)

 

Analysis: DP large amount of data can not be used, an idea is to enumerate the number of articles A, and the rest are put b

A kind of thinking is to take two in a and b are compared to see which big, B large, then put B, or put two A.

 


stBracket Sequence

 

CF3D Least Cost Bracket Sequence

Guess you like

Origin www.cnblogs.com/qq1775753648/p/11839190.html