Ternary ring: How many elements of a ternary set are found in a number set 22 coprime

Source: Internet
Author: User

2.14 attend the training in Hangzhou second, the campus is very beautiful!!! Qaq

Duchi in the afternoon for everyone to do the morning three lectures and some CF miscellaneous problems of the selection, which have on the graph to find all ternary ring algorithm. This algorithm is not very complicated, but it's pretty interesting. Qwq

We have a number of integers, recorded as A1,a2,..., an. We want to find out that several of these numbers have a subset of three elements that satisfy the problem, namely {Ai,aj,ak} (Ai,aj) =1 and (Ai,ak) =1 and (Aj,ak) = 1.

The first step is to build the map. The A1,A2,... an is treated as a point numbered,..., N, and if the AI and AJ Coprime, a non-lateral edge is formed between the node I and the node J.

Step two, sort. Sorts the degrees of each node in a certain order (for example, from large to small), then adjusts the non-directed graph to a directed graph based on the resulting sort (for example, the direction of the edge is determined to point from a node with a high degree to a low degree). This will avoid the situation: I->j->k->i. Here's what happens: I->j->k<-i.

The third step, enumeration. First, the node I is identified, enumerating the edges starting from two I, assuming pointing to j,k respectively. If there is an edge between J and K, then the i,j,k constitutes a ternary ring, that is, Ai,aj,ak satisfies the condition of the problem. So the enumeration can be done not heavy not leak oh.

The time complexity of the algorithm can be proved by the case of O ((2m) ^ (3/2)).

Ternary ring: How many elements of a ternary set are found in a number set 22 coprime

Related Article

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.