[BZOJ1004] [HNOI2008] Cards Problem Solving report (Burnside lemma)

Source: Internet
Author: User

Description

Koharu is now very quiet, facing the desk of the n cards, he decided to give each stain, the current Koharu only 3 colors: red, blue, green. He asked Sun how many kinds of staining options he had, and sun quickly gave the answer. Further, Koharu asked to dye SR red, SB-Blue, SG Zhang. He asked how many options he had, and sun thought about it and gave the correct answer. Finally Koharu invented M different shuffle methods, where he asked Sun how many different staining schemes. Two staining methods are the same when and only if one of them can be used by arbitrary shuffle method (that is, you can use a variety of shuffle method, and each method can be used several times) to wash into another. Sun found the problem a bit difficult, and decided to give it to you, the answer may be very large, just ask for the answer divided by the remainder of P (p is prime).

    This problem has been done for a long time ... Feeling or the Burnside lemma understanding is not thorough it.

   Burnside lemma:

l=1/| g|* (c1+c2+...ck), CI denotes the fixed permutation class for the permutation of type I. such as Displacement: (123) (45) (6) The Fixed displacement class only (6) one.

This problem can not be used Polya theorem, because each color has a specific quantity requirements, can not be arbitrarily dyed.

The shuffle method given in the title is obviously a replacement. So what do you want to do with a replacement class?

The same color looks the same, so if the color of the position after displacement is the same as the original position, it is still a displacement class.

And this question needs to be considered, how we should bring the dyeing scheme to the formula.

The answer is to consider a staining scheme as an element.

That is, the fixed displacement class in this problem is a dyeing scheme that remains unchanged after the permutation.

Then the number of invariant permutation classes, namely CI, is to satisfy the total number of staining schemes with the same color on each one after I have been replaced.

The same color is dyed in each cycle, and the number of scenarios can be calculated using 01 backpacks.

    Finally, we must not forget the most important is the most basic of a permutation namely (1) (2) (3) ... (n) this permutation.

In the process of implementation, it is necessary to use the multiplication inverse element. A little attention can be.

     

Program bzoj1004;Constmaxn= $;varI,j,t1,t2,t3:longint;    S1,s2,s3,m,p,n,ans,tot,sum,x:int64; f:array[-1.. maxn,-1.. maxn,-1..    Maxn]of Int64; vis:array[-1..    Maxn]of Boolean; a:array[-1.. Maxn]of longint;function ex_euclid (a,b:int64;varX,y:int64): Int64;varT:int64;beginifb=0Then begin x:=1; y:=0; exit (a); EndElsebegin Ex_euclid:=ex_euclid (b,a mod b,x,y); T:=x;x:=y;y:=t-(a div b) *y; End;end;function Inverse (A:int64): Int64;varX,y,tem,d:int64;begin D:=Ex_euclid (a,p,x,y); ifD<>1Then exit (-1)Elsebeginifx<0Then begin TEM:=(-x) div p; X:=x+tem*p;y:=y-tem*A;        End ifx<0Then begin x:=x+p;y:=y-p;    End    End Exit (x); End;begin readln (S1,s2,s3,m,p); N:=s1+s2+S3; Ans:=1;  fori:=2to n DoAns:= (ans*i) mod p;  fori:=2to S1 DoAns:= (ans*Inverse (i)) mod p;  fori:=2to S2 DoAns:= (ans*Inverse (i)) mod p;  fori:=2to S3 DoAns:= (ans*Inverse (i)) mod p;  fori:=1to M Dobegin Fillchar (F,sizeof(f),0); Fillchar (Vis,sizeof(VIS),true); f[0,0,0]:=1; sum:=0;  forj:=1to n Doread (a[j]); readln;  forj:=1to n Do ifVis[j] THEN BEGIN tot:=0; X:=a[j];vis[j]:=false;  whileX<>j DoBegin Inc (TOT); VIS[X]:=false; X:=A[x];            End            Inc (Sum,tot);  fort1:=0To sum Do                 fort2:=0To Sum-t1 Dobegin T3:=sum-t1-T2; ift1-tot>=0Then f[t1,t2,t3]:= (f[t1,t2,t3]+f[t1-TOT,T2,T3])                    MoD p; ift2-tot>=0Then f[t1,t2,t3]:= (f[t1,t2,t3]+f[t1,t2-TOT,T3])                    MoD p; ift3-tot>=0Then f[t1,t2,t3]:= (f[t1,t2,t3]+f[t1,t2,t3-tot])                MoD p;        End    End    End Ans:= (Ans*inverse (m+1) mod p; Writeln (ans); end.

 

      

[BZOJ1004] [HNOI2008] Cards Problem Solving report (Burnside lemma)

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.