Test instructions
Give a C color and s beads;
The beads are dyed and worn into a ring;
Rotate and flip the same as isomorphic;
The number of solutions to be obtained;
Exercises
Polya the number of naked questions;
Define m as the number of colors, and C (PI) as the number of cyclic sections of pi for this permutation;
So according to the theorem, the answer is L;
Then just find out the various permutations of the cycle section is good;
Two permutations are allowed in the problem, first consider rotation;
Rotation there are n substitution methods, respectively, is 0, turn 360/n, turn 2*360/n ... Turn (n-1) *360/n;
The number of cycles of each type is actually GCD, and then the sum is brought into the summation form;
Then consider flipping, with odd-even discussions;
Odd can cross each bead to do the axis of symmetry, then the permutation number is n, the link number is n/2+1;
Even can be over two diagonal beads do the axis of symmetry, displacement number is N/2, the number of links is n/2+1 (other beads divided by 2, plus two on the axis);
can also but beads, such displacement number is also N/2, the number of links is N/2;
And then it ended with a 2*n;
Code:
#include <stdio.h> #include <string.h> #include <algorithm> #define N 110000using namespace std; typedef long LONG Ll;int gcd (int a,int b) {int t=a%b;while (t) {a=b,b=t;t=a%b;} return b;} int pow (int x,int y) {int ret=1;while (y) {if (y&1) ret*=x;x*=x;y>>=1;} return ret;} int main () {int n,m,i,j,k;while (scanf ("%d%d", &m,&n) && (n| | m) {for (i=1,k=0;i<=n;i++) K+=pow (M,GCD (n,i)), if (n&1) K+=n*pow (m,n/2+1); Elsek+=n/2*pow (M,N/2) +n/2*pow (m,n/ 2+1); k/=2*n;printf ("%d\n", k);} return 0;}
poj-2409 Let It bead