Codeforces round 160 (full)

Source: Internet
Author: User

Again kneeling... Continue. Stick to it !!

Codeforces 261b

First, use a backpack to process a DP array, and then enumerate each separator (that is, the preceding number plus this number exceeds p) to calculate all the quantities, and then calculate directly ,,

Http://www.codeforces.com/contest/261/submission/2921844


Codeforces 261c

First, we can calculate the number of rows in the m + 1 (draw a picture to obtain the Law): Given A m, the number of rows 1 in m + 1 is 2 ^ (bit_count (m + 1)-1), so t must be the exponential power of 2. Otherwise, the answer is 0.

Now the problem is converted to the binary representation of several numbers from 2 to n + 1, where p + 1 is 1, (2 ^ P = T). Let's take a look at the typical digital DP.

DP [I] [J] indicates the number of binary numbers with a length of J 1. After preprocessing, you can directly calculate the number.

Http://www.codeforces.com/contest/261/submission/2922990


Codeforces 261d

I feel that it is hard to understand the meaning of the question ....

Give you k rows, each row has n numbers, and then rewrite the N numbers t times connected, ask you about the new sequence (total N * T number) the maximum length of the incremental sub-sequence is.

There are several important points to note: ensure that all numbers cannot exceed maxb, and maxb * n cannot exceed 10 7 times.

The CF server is sharp, as if the computing workload of several memories can flow, that is, brute force. After finding the sequence, you can use an nlogn algorithm to find the longest incrementing subsequence.

The complexity should be K * 10 ^ 7 * log (maxb ).

Paste a tree array below, which is equivalent to using a tree array to optimize a n * maxb DP

Http://www.codeforces.com/contest/261/submission/2951761


Although the above practices take into account the nature of the series, there are still better methods.

Worship lzqxh code .... Thinking ....

Considering the nature of the series, the length is very long (10 ^ 7), but because maxb (10 ^ 5) is the maximum number, we can consider this status, DP [I] indicates the length of the longest incrementing sub-sequence ending with I, if the current number is

If the length of the longest incremental sub-sequence is Len, we should look for the number B smaller than a, and then judge whether DP [B] + 1 can update DP [a], what kind of length can be updated to DP [a]? It must be DP [a] + 1, so we should find the number with the length of DP [a] and smaller than a and connect to, in addition, if DP [a] = Len + 1, you do not need to update it any more, because adding a "A" can increase the length of the longest incremental sequence by 1 at most. Since it has increased by 1, you do not need to update it again.

The last clever way is to map the last number of DP values to X using an array, that is, num [DP [x] = X; you only need to use this array to find the number of DP [a] characters. I want to know why. The TMP = num [DP [a] record must be the minimum number in the number (end) with the current length of DP [, because if there are still numbers with a length of DP [a] earlier than TMP, then TMP can be connected so that the length at TMP should be longer, instead of DP [A]. Each DP [I] can increase CNT times at most. CNT is the number of numeric types, so the complexity is CNT * CNT. Because CNT <= N and CNT <= maxb, CNT * CNT
<= N * maxb <= 10 ^ 7

Http://www.codeforces.com/contest/261/submission/2953464

Codeforces 261e

Question: at the beginning, we will give you two numbers. If the number is 0, we can add one to the number + 1 on the right, or we can multiply the number on the left and return it to the left, ask how many operations X (L <= x <= r) can appear on the left. The number of operations required is less than or equal to P.

Note that P <= 100, we can find that X is certainly composed of prime numbers smaller than or equal to 100. Then there is a breakthrough in the question, handling the number of all prime factors within 100, there are about 300 or 0000 such numbers within 1 E9 (What do I think of Nima !!), If DP [I] is set, the number of I operations can be obtained at least a few times. The next thing to do is to enumerate the operations performed several times on the right side, directly update the DP through dual-cycle violence. DP [J] must be updated by a [k] * I = A [J, here, K does not need to be enumerated. After sorting all the numbers, we can use monotonicity to constantly move to the right.

Http://www.codeforces.com/contest/261/submission/2958347

Summary: in this competition, DP is quite a lot, and the thinking is very flexible. Generally, it is very simple to cover a layer of uneasily seen descriptions (I am more careful ..) That is to say, adding something to the general DP is a great test of thinking ,,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.