Burnside引理和polay计数 poj2409 Let it Bead
题目描述
"Let it Bead" company is located upstairs at 700 Cannery Row in Monterey, CA. As you can deduce from the company name, their business is beads. Their PR department found out that customers are interested in buying colored bracelets. However, over 90 percent of the target audience insists that the bracelets be unique. (Just imagine what happened if two women showed up at the same party wearing identical bracelets!) It's a good thing that bracelets can have different lengths and need not be made of beads of one color. Help the boss estimating maximum profit by calculating how many different bracelets can be produced.
A bracelet is a ring-like sequence of s beads each of which can have one of c distinct colors. The ring is closed, i.e. has no beginning or end, and has no direction. Assume an unlimited supply of beads of each color. For different values of s and c, calculate the number of different bracelets that can be made.
输入
Every line of the input file defines a test case and contains two integers: the number of available colors c followed by the length of the bracelets s. Input is terminated by c=s=0. Otherwise, both are positive, and, due to technical difficulties in the bracelet-fabrication-machine, cs<=32, i.e. their product does not exceed 32.
输出
For each test case output on a single line the number of unique bracelets. The figure below shows the 8 different bracelets that can be made with 2 colors and 5 beads.
样例输入
1 1
2 1
2 2
5 1
2 5
2 6
6 2
0 0
样例输出
1
2
3
5
8
13
21
提示
前言:
通过这道题深入了解一下burnside和polya,我尽力用简单朴素的方式理解
简述题意:
一个长为n的手镯,每个珠子可以染成k中颜色中的一种,求本质不同的染色方案有多少种?(可以旋转、翻转
burnside是用来求关于一个置换群下有多少本质不同的染色方案的
#include<cstdio>
#define ll long long
using namespace std;
int n,k;
ll ans;
ll gcd(ll a,ll b){
if(!b)return a;
return gcd(b,a%b);
}
ll ksm(ll x,ll t){
ll ans=;
for(;t;t>>=,x*=x)if(t&)ans*=x;
return ans;
}
int main(){
while(scanf("%d%d",&k,&n)){
if(n==&&k==)break;
ans=;
for(int i=;i<=n;i++)ans+=ksm(k,gcd(i,n));
if(n&)ans+=ksm(k,(n+)/)*n;
else{
ans+=ksm(k,(n+)/)*n/;
ans+=ksm(k,n/)*n/;
}
ans/=*n;
printf("%lld\n",ans);
}
return ;
}
Burnside引理和polay计数 poj2409 Let it Bead的更多相关文章
- Burnside引理和polay计数学习小记
在组合数学中有这样一类问题,比如用红蓝两种颜色对2*2的格子染色,旋转后相同的算作一种.有多少种不同的染色方案?我们列举出,那么一共有16种.但是我们发现,3,4,5,6是同一种,7,8,9,10是用 ...
- Burnside引理和Polya定理之间的联系
最近,研究了两天的Burnside引理和Polya定理之间的联系,百思不得其解,然后直到遇到下面的问题: 对颜色限制的染色 例:对正五边形的三个顶点着红色,对其余的两个顶点着蓝色,问有多少种非等价的着 ...
- Burnside引理和Polya定理
转载自:https://blog.csdn.net/whereisherofrom/article/details/79631703 Burnside引理 笔者第一次看到Burnside引理那个公式的 ...
- Burnside引理与polay定理
#Burnside引理与polay定理 引入概念 1.置换 简单来说就是最元素进行重排列 是所有元素的异议映射,即\([1,n]\)映射到\([1,n]\) \[ \begin{pmatrix} 1& ...
- polay计数原理
公式: Burnside引理: 1/|G|*(C(π1)+C(π2)+C(π3)+.....+C(πn)): C(π):指不同置换下的等价类数.例如π=(123)(3)(45)(6)(7),X={1, ...
- poj2409 Let it Bead
Let it Bead Time Limit: 1000MS M ...
- POJ 2409 Let it Bead(polay计数)
题目链接:http://poj.org/problem?id=2409 题意:给出一个长度为m的项链,每个珠子可以用n种颜色涂色.翻转和旋转后相同的算作一种.有多少种不同的项链? 思路: (1) 对于 ...
- Luogu P5564 [Celeste-B]Say Goodbye (多项式、FFT、Burnside引理、组合计数)
题目链接 https://www.luogu.org/problem/P5564 题解 这题最重要的一步是读明白题. 为了方便起见下面设环长可以是\(1\), 最后统计答案时去掉即可. 实际上就相当于 ...
- BZOJ 1488 Luogu P4727 [HNOI2009]图的同构 (Burnside引理、组合计数)
题目链接 (Luogu) https://www.luogu.org/problem/P4727 (BZOJ) https://www.lydsy.com/JudgeOnline/problem.ph ...
随机推荐
- C++成员对齐方式探讨
本文參考了<高质量程序设计指南--C++/C语言>一书 有不妥之处恳请指正 一.自然对齐 某些基于RISC(精简指令集)的CPU比方SPARC.PowerPC等.採用高字节和高字在低地址存 ...
- POJ2481:Cows(树状数组)
Description Farmer John's cows have discovered that the clover growing along the ridge of the hill ( ...
- WinMain和MFC的差别
API(Application Programming Interface):开放给应用程序调用的系统功能. 一个Windows Application(SDK): WinMain ReristerC ...
- zedboard 流水灯
#include"xparameters.h"/* Peripheral parameters 外围的參数 */ #include"xgpio.h"/* GPI ...
- 让mongodb执行js文件
环境: Linux js代码: 循环删除表中的数据: clear-mongodb-dialog.js print('=========BEGIN=========='); for(var i of [ ...
- Linux如何使用cURL分割下载大文件
Linux如何使用cURL分割下载大文件 - 51CTO.COM http://os.51cto.com/art/201508/489368.htm
- uboot的GPIO驱动分析--基于全志的A10芯片【转】
本文转载自:http://blog.csdn.net/lw2011cg/article/details/68954707 uboot的GPIO驱动分析--基于全志的A10芯片 转载至:http://b ...
- python - list 列表推导式
一.如有两个list,分别为: a = [1,2,3,4,5,6]b = ["a","b","c","d"," ...
- Java学习-异常2
1.异常处理的第一种方式是:上抛[throws] 2.异常处理的第二种方式是:try....catch..如果不想让调用程序知道该异常发生了,被调用的程序应该使用try...catch..进行异常捕捉 ...
- Python 如何在csv中定位非数字和字母的符号
在数据清洗过程中,有时不仅希望去掉脏数据,更希望定位脏数据的位置,例如从csv里面定位非数字和字母单元格的位置,在使用isdigit().isalpha().isalnum()时无法判断浮点数,会将浮 ...