[Codevs 1995] the door to the black magician (and query set)

Source: Internet
Author: User

Title: http://codevs.cn/problem/1995/

Analysis: the subgraph that satisfies the requirements of the question must be a ring ...... Then the question becomes the number of rings that are constantly added to the edge. It looks a little troublesome ...... But the essence of the ring is the combination of several small rings ...... So we only need to know the number of the most basic rings. According to the binary theorem, It is 2 ^ (the number of the most basic rings)-1. It's still hard to do !!!!!!

It doesn't matter ...... And found ......

Assuming that the final answer to the I-1 operation is ans, there are two scenarios for the I operation:

① If a new ring does not appear after this edge is added, it indicates that the result is not affected and the result is still ans.

② After this edge is added, a new ring appears. So for the previous ans ring, we can help this new ring to put in a combination as a new ring, so ans * 2, but note that we have a new basic ring, so ans = ans * 2 + 1

So the perfect solution ......

[Codevs 1995] the door to the black magician (and query set)

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.