题意

用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. 【mlflow】打包:npm run build + python setup.py sdist

    mlflow是一个开源机器学习平台 最近需要使用一个它的最新版本,但是这个最新版本没有git包,无法通过pip install安装,需要打包安装. 打包完之后在项目的dist文件夹中有打包后的压缩包, ...

  2. find the safest road---hdu1596(最短路模板求最大概率)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1596 求给定的任意两点之间的最大安全概率,概率之间是相乘的关系,所以注意初始化即可 #include& ...

  3. Python开发【模块】:time、datatime

    时间模块 时间相关的操作,时间有三种表示方式: 时间戳               1970年1月1日之后的秒,即:time.time() 格式化的字符串    2014-11-11 11:11,   ...

  4. 当IDENTITY_INSERT设置为OFF时不能向表插入显示值。(源:MSSQLServer,错误码:544)

    错误提示"事务和快照同步时提示:当IDENTITY_INSERT设置为OFF时不能向表插入显示值.(源:MSSQLServer,错误码:544)" 原因:在SQL2008同步时到S ...

  5. java-mybaits-00101-基础安装配制

    一.数据库安装 http://jingyan.baidu.com/article/363872ec2e27076e4ba16fc3.html 二.eclipse连接mysql http://jingy ...

  6. Java线程池ThreadPoolExecuter:execute()原理

    一.线程池执行任务的流程 如果线程池工作线程数<corePoolSize,创建新线程执行task,并不断轮训t等待队列处理task. 如果线程池工作线程数>=corePoolSize并且等 ...

  7. Python:笔记(7)——yield关键字

    Python:笔记(7)——yield关键字 yield与生成器 所谓生成器是一个函数,它可以生成一个值的序列,以便在迭代中使用.函数使用yield关键字可以定义生成器对象. 一个例子 我们调用该函数 ...

  8. Codeforces Round #523 (Div. 2) Solution

    A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (sc ...

  9. Python: 使用生成器创建新的迭代模式

    使用一个生成器函数来定义一个函数模式. def frange(start, stop, increment): x = start while x < stop: yield x x += in ...

  10. poj1942 Paths on a Grid(无mod大组合数)

    poj1942 Paths on a Grid 题意:给定一个长m高n$(n,m \in unsigned 32-bit)$的矩形,问有几种走法.$n=m=0$时终止. 显然的$C(m+n,n)$ 但 ...