POJ 2409 Let it Bead (Polya定理)
题意
用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定理)的更多相关文章
- poj 2409 Let it Bead Polya计数
旋转能够分为n种置换,相应的循环个数各自是gcd(n,i),个i=0时不动,有n个 翻转分为奇偶讨论,奇数时有n种置换,每种有n/2+1个 偶数时有n种置换,一半是n/2+1个,一半是n/2个 啃论文 ...
- [ACM] POJ 2409 Let it Bead (Polya计数)
参考:https://blog.csdn.net/sr_19930829/article/details/38108871 #include <iostream> #include < ...
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...
- POJ 2409 Let it Bead:置换群 Polya定理
题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...
- POJ 2409 Let it Bead(Polya定理)
点我看题目 题意 :给你c种颜色的n个珠子,问你可以组成多少种形式. 思路 :polya定理的应用,与1286差不多一样,代码一改就可以交....POJ 1286题解 #include <std ...
- poj 2409 Let it Bead【polya定理+burnside引理】
两种置换 旋转:有n种,分别是旋转1个2个--n个,旋转i的循环节数位gcd(i,n) 翻转:分奇偶,对于奇数个,只有一个珠子对一条边的中点,循环节数为n/2+1:对于偶数个,有珠子对珠子和边对边,循 ...
- POJ 2409 Let it Bead(polya裸题)
题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...
- POJ 2409 Let it Bead 组合数学
题目地址: http://poj.org/problem?id=2409 给你一串珠子有m个,用n种不同的颜色涂色,问有多少种分法. 用polay定理求解,对于排成一排的带编号的小球,按照某一种方案改 ...
- 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:/ ...
随机推荐
- iOS定位原理和使用建议(转)
原文:http://ibbs.91.com/thread-1548870-1-1.html 看到很多网友讨论iOS设备定位的问题,这里将我们所了解的关于iPhone.iPad.iPod等的定位原理做详 ...
- python模块之xlrd(excl调用模块)
一.安装xlrd模块 到python官网下载http://pypi.python.org/pypi/xlrd模块安装,前提是已经安装了python 环境. 二.使用介绍 1.导入模块 import x ...
- ubuntu 搭建ftp服务器,可以通过浏览器访问,filezilla上传文件等功能
搭建ftp服务器 1:首先,更新软件源,保证源是最新的,这样有利于下面在线通过apt-get install命令安装ftp. 2:使用sudo apt-get install vsftp命令安装vsf ...
- 一个Spark job的生命历程
一个job的生命历程 dagScheduler.runJob //(1) --> submitJob ( eventProcessLoop.post(JobSubmitted,***) //(2 ...
- 二、 Mosquitto 使用说明
一. 继上一篇文章<<Mosquitto 介绍&安装>> 之后.本章介绍 Mosquitto 的 简单使用. 1> 创建用户 # groupadd mosquit ...
- testng日志和报告
TestNG是通过 Listeners 或者 Reporters 生成测试报告. Listeners,即 org.testng.ITestListener 的实现,能够在测试执行过程中发出各种测试结果 ...
- EditPlus 4.3.2477 中文版已经发布(11月3日更新)
新的版本修复了之前版本文本库和自动完成功能中的“^!”符号在填充项前面时不能正常工作的问题.
- sysctl.conf文件详解
本文转自:http://www.cnblogs.com/Rosanna/p/3446557.html 使文件立刻生效命令:/sbin/sysctl -p /proc/sys目录下存放着大多数内核参数, ...
- laravel 项目部署注意事项
1.'Failed to open stream: Permission denied' error - Laravel Laravel >= 5.4 php artisan cache:cle ...
- P1083 借教室(差分+二分)
P1083 借教室 第一眼:线段树. 然鹅懒得写. 正解:差分+二分. 显然订单合法的上线可以二分 然后差分数组维护一下.没了. #include<iostream> #include&l ...