UVa 10294 (Pólya count) Arif in Dhaka (First love part 2)

Source: Internet
Author: User

Burnside theorem: If a coloring scheme s is changed after substitution F, it is called S is the fixed point of F, the number of fixed points of displacement F is recorded as C (f). The number of equivalence classes equals the average of all C (f).

A necklace, a bracelet, the difference is that one can flip a can't, use T color dye n beads, the number of equivalence classes.

Rotation permutation group There are total n permutations, respectively, corresponding to the whole necklace counterclockwise rotation 0, one, 2 ... The substitution of beads.

For the first permutation, No. 0, I, 2i ... A bead consists of a cycle of GCD (n, i) loops with N/GCD (n, i) beads in each cycle.

So n permutations, the fixed points of each permutation have tgcd (i, N).

For a reversed permutation group, there are two conditions based on the odd-even division of N:

    • n is odd, the symmetric axis has n, each passes through a bead, each permutation has (n+1)/2 loops, including (n-1)/2 2-length loops and a 1-length cycle (that is, the bead that crosses). So the total number of fixed points is NT (n+1)/2
    • n is even, there are n/2 through the beads of the symmetrical axis, each axis of symmetry through two beads. There are a total of n/2+1 loops, including n/2-1 with a 2-length loop and 2 1-length loops, and a symmetric axis with N/2 that does not pass through the beads, with a total of N/2 2-length loops.

Another A = sum{tgcd (M, i) | 0≤i≤n-1}

If n is odd, B = NT (n+1)/2

If n is even, B = n/2 * (t (n/2+1) + TN/2)

The answers are a/n and (a+b)/(2n) respectively.

1#include <cstdio>2typedefLong LongLL;3 4 intgcdintAintb)5{returnb = =0? A:GCD (b, a%b); }6 7 Const intMAXN = -;8 LL P[MAXN];9 Ten intMain () One { A     //freopen ("In.txt", "R", stdin); -  -p[0] =1; the     intN, t; -      while(SCANF ("%d%d", &n, &t) = =2) -     { -          for(inti =1; I <= N; i++) P[i] = p[i-1] *T; +LL A =0, B =0; -          for(inti =0; I < n; i++) A + =P[GCD (n, i)]; +         if(N &1) b = n * p[(n+1)/2]; A         Elseb = n/2* (p[n/2+1] + p[n/2]); atprintf"%lld%lld\n", a/n, (a+b)/n/2); -     } -  -     return 0; -}
code June

UVa 10294 (Pólya count) Arif in Dhaka (First love part 2)

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.