题意

用k种颜色对n个珠子构成的环上色,旋转翻转后相同的只算一种,求不等价的着色方案数。

思路


Polya定理

X是对象集合{1, 2, ……, n}, 设G是X上的置换群,用M种颜色染N种对象,则不同的染色方案数为:

λ(g)表示置换g的轮换个数,且λ(g) = λ1(g) + λn(g) + …… + λn(g),其中λi(g)表示g中长度为i的轮换(循环)个数.


本题是对一个n个珠子的圆珠的颜色,而圆珠的置换群有:

Ⅰ翻转:1.当n为奇数时,有n种翻转,每种翻转的轴都是一个顶点和该顶点对边中点的连线,有n种置换,每种置换的轮换个数均为(n/2+1)。

2.当n为偶数时,有n种翻转,其中n/2种转轴是两个对应顶点连线,轮换个数为n/2+1;另n/2种转轴是两条对边中点的连线,轮换个数为n/2。

Ⅱ旋转:枚举旋转角度360/n*i,有n种旋转;第i种旋转有gcd(n, i)个轮换,每个轮换的长度都是n/gcd(n, i)。

然后带入公式即可.

代码

[cpp]
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#define MID(x,y) ((x+y)/2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define REP(i, begin, end) for (int i = begin; i <= end; i ++)
using namespace std;

int gcd(int a, int b){
return b?gcd(b, a%b):a;
}
int main(){
//freopen("test.in", "r", stdin);
//freopen("test.out", "w", stdout);
int c, s;
while(scanf("%d %d", &c, &s) != EOF){
long long res = 0;
if (c + s == 0) break;
if (s % 2 == 1){
res += (long long)s * pow(c, s/2+1);
}
else{
res += (long long)(s/2) * (pow(c, s/2) + pow(c, s/2+1));
}
for (int i = 1; i <= s; i ++){
res += (long long)pow(c, gcd(s, i));
}
printf("%I64d\n", res/2/s);
}
return 0;
}
[/cpp]

POJ 2409 Let it Bead (Polya定理)的更多相关文章

  1. poj 2409 Let it Bead Polya计数

    旋转能够分为n种置换,相应的循环个数各自是gcd(n,i),个i=0时不动,有n个 翻转分为奇偶讨论,奇数时有n种置换,每种有n/2+1个 偶数时有n种置换,一半是n/2+1个,一半是n/2个 啃论文 ...

  2. [ACM] POJ 2409 Let it Bead (Polya计数)

    参考:https://blog.csdn.net/sr_19930829/article/details/38108871 #include <iostream> #include < ...

  3. poj 1286 Necklace of Beads &amp; poj 2409 Let it Bead(初涉polya定理)

    http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...

  4. POJ 2409 Let it Bead:置换群 Polya定理

    题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...

  5. POJ 2409 Let it Bead(Polya定理)

    点我看题目 题意 :给你c种颜色的n个珠子,问你可以组成多少种形式. 思路 :polya定理的应用,与1286差不多一样,代码一改就可以交....POJ 1286题解 #include <std ...

  6. poj 2409 Let it Bead【polya定理+burnside引理】

    两种置换 旋转:有n种,分别是旋转1个2个--n个,旋转i的循环节数位gcd(i,n) 翻转:分奇偶,对于奇数个,只有一个珠子对一条边的中点,循环节数为n/2+1:对于偶数个,有珠子对珠子和边对边,循 ...

  7. POJ 2409 Let it Bead(polya裸题)

    题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...

  8. POJ 2409 Let it Bead 组合数学

    题目地址: http://poj.org/problem?id=2409 给你一串珠子有m个,用n种不同的颜色涂色,问有多少种分法. 用polay定理求解,对于排成一排的带编号的小球,按照某一种方案改 ...

  9. bzoj 1004 [HNOI2008]Cards && poj 2409 Let it Bead ——置换群

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004 http://poj.org/problem?id=2409 学习材料:https:/ ...

随机推荐

  1. vue - nodejs

    一.知识 打开Nodejs英文网:https://nodejs.org/en/ 中文网:http://nodejs.cn/ 我们会发现这样一句话: 翻译成中文如下: Node.js 是一个基于 Chr ...

  2. Linux下编译安装PHP扩展memcached

    [安装 libevent] $ tar zxvf libevent-2.0.20-stable.tar.gz $ cd libevent-2.0.20-stable/$ ./configure --p ...

  3. Exception in thread "main" java.lang.NoClassDefFoundError: scala/Product$class

    在使用spark sql时一直运行报这个错误,最后仔细排查竟然是引入了两个scala library .去除其中一个scala的编译器即可 Exception in thread "main ...

  4. POJ2115:C Looooops(一元线性同余方程)

    题目: http://poj.org/problem?id=2115 要求: 会求最优解,会求这d个解,即(x+(i-1)*b/d)modm;(看最后那个博客的链接地址) 前两天用二元一次线性方程解过 ...

  5. 6.2 Controllers -- Representing Multipe Models

    1. 一个controller的model可以代表几个记录也可以代表单个.这里,路由的model hook返回一个歌曲数组: app/routes/songs.js export default Em ...

  6. 52. N-Queens II(数个数)

    The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens ...

  7. ng-深度学习-课程笔记-7: 优化算法(Week2)

    1 Mini-batch梯度下降 在做梯度下降的时候,不选取训练集的所有样本计算损失函数,而是切分成很多个相等的部分,每个部分称为一个mini-batch,我们对一个mini-batch的数据计算代价 ...

  8. python webdriver api-操作富文本框

    操作富文本框-就是邮件正文部分,可以选字体啥的 第一种方式: 一般都是在iframe里,要切进去,一般是”html/body”,编辑之后,再切出来,然后再send_keys就完事儿 #encoding ...

  9. Qt的信号和槽是如何工作的

    用Qt做过开发的朋友,不知道是否曾为下面这些问题疑惑过:我们知道Qt是基于C++的,Qt写的代码最终还是要由C++编译器来编译,但是我们的Qt代码中有很多C++里没有的关键字,比如slots\sign ...

  10. HDU1978How Many Ways 记忆化dfs+dp

    /*记忆化dfs+dp dp[i][j]代表达到这个点的所有路的条数,那么所有到达终点的路的总数就是这dp[1][1]加上所有他所能到达的点的 所有路的总数 */ #include<stdio. ...