1 model (2) day1

Source: Internet
Author: User

Question 1:

Question:

Set 2n cards to marked as 1, 2,..., n, n + 1,..., 2n. At the beginning, the 2N cards are marked as small to large
. After a shuffling, the original order becomes n + 1, 1, n + 2, 2,..., 2n, N. That is, the first n cards are placed
An even number is 2, 4,..., 2n, and then n cards are placed in an odd number of positions: 1, 3,..., 2n-1. It can prove to any
Number of Natural Numbers N. After several shuffling, the initial state can be restored. Now your task is to calculate the value (n ≤ 10 ^ 5) for the given n ),
The minimum number of shuffles required to restore to the initial state.

 

Problem solving process:

1. Simulate absolute timeout, and then start to find the rule. For the number of X at the current position, if X <= N, it will run to the location of 2 * X next time. Otherwise it will run to the location of (2 * x-1) mod (2 * n.

2. After a manual simulation, I feel that as long as a number is returned to the original position and other numbers are returned, I will take location 1 and follow the rule to simulate it. Then I will be confused about the AC.

3. After the test, I cannot understand why I just need to take any number. As a result, TMD found a counterexample: WHEN n = 10;

If the number of Position 1 is obtained at the beginning, its location change is 1-> 2-> 4-> 8-> 16-> 11-> 1, then the answer is 6.

If the number of position 3 is obtained at the beginning, its position changes to 3-> 6-> 12-> 3-> 6-> 12-> 3.

It can be found that after 3rd shuffling, the number of position 3 is returned to the original position, but the number of Position 1 is not yet. If the number of position 3 is selected at the beginning, the answer will be 3.

Is it possible to select the number of positions 1 at the beginning to enable AC ?? Fuck test my RP .. Please explain it !!!!! A group of silly questions on the network all say, "Because the moving rules are the same, as long as any number is returned to the original position, and the other numbers are also returned to the original position", it is a pleasant one, then enjoy the AC. I personally think this is an extremely disrespectful respect for the person who asked the question...

 

Question 2:

Questions: Old questions, merged fruit .. I reviewed the heap.

 

Question 3:

Answer: Solve the Problem of Data independence.

Problem solving process:

1. the DFS search + hash is faster. The slowest speed was 0.96 s, and it almost crashed. See my solution report for noip2009 target-type Sudoku. Http://www.cnblogs.com/vb4896/p/3881250.html

2. Study ing link .. All data in the bidding process is killed in 0 ms.

 

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.