【POJ 2409】 Let it Bead(置换、burnside引理)
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.
Input
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.Output
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.
Sample Input
1 1
2 1
2 2
5 1
2 5
2 6
6 2
0 0Sample Output
1
2
3
5
8
13
21
要考虑旋转和翻转。
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define Maxn 60
#define LL long long LL pw[]; int gcd(int a,int b)
{
if(b==) return a;
return gcd(b,a%b);
} int main()
{
int n,t;
while()
{
scanf("%d%d",&t,&n);
if(n==&&t==) break;
pw[]=;
for(int i=;i<=n;i++) pw[i]=pw[i-]*t;
LL a=;
for(int i=;i<n;i++) a+=pw[gcd(i,n)];
LL b=;
if(n%==) b=n*pw[(n+)/];
else b=n/*(pw[n/+]+pw[n/]);
printf("%lld\n",(a+b)//n);
}
return ;
}
2017-01-13 11:43:09
【POJ 2409】 Let it Bead(置换、burnside引理)的更多相关文章
- POJ 2409 Let it Bead(polay计数)
题目链接:http://poj.org/problem?id=2409 题意:给出一个长度为m的项链,每个珠子可以用n种颜色涂色.翻转和旋转后相同的算作一种.有多少种不同的项链? 思路: (1) 对于 ...
- POJ 2409 Let it Bead:置换群 Polya定理
题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...
- bzoj 1004 Cards & poj 2409 Let it Bead —— 置换群
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004 关于置换群:https://www.cnblogs.com/nietzsche-oie ...
- 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:/ ...
- BZOJ_[HNOI2008]_Cards_(置换+Burnside引理+乘法逆元+费马小定理+快速幂)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1004 共n个卡片,染成r,b,g三种颜色,每种颜色的个数有规定.给出一些置换,可以由置换得到的 ...
- 【BZOJ1004】【HNOI2008】Cards 群论 置换 burnside引理 背包DP
题目描述 有\(n\)张卡牌,要求你给这些卡牌染上RGB三种颜色,\(r\)张红色,\(g\)张绿色,\(b\)张蓝色. 还有\(m\)种洗牌方法,每种洗牌方法是一种置换.保证任意多次洗牌都可用这\( ...
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...
- poj 1286 Necklace of Beads poj 2409 Let it Bead HDU 3923 Invoker <组合数学>
链接:http://poj.org/problem?id=1286 http://poj.org/problem?id=2409 #include <cstdio> #include &l ...
- poj 2409 Let it Bead【polya定理+burnside引理】
两种置换 旋转:有n种,分别是旋转1个2个--n个,旋转i的循环节数位gcd(i,n) 翻转:分奇偶,对于奇数个,只有一个珠子对一条边的中点,循环节数为n/2+1:对于偶数个,有珠子对珠子和边对边,循 ...
- POJ 2409 Let it Bead ——Burnside引理
[题目分析] 裸题直接做. 一个长度为n,颜色为m的环,本质不同的染色方案是多少. 数据范围比较小,直接做就好了. [代码] #include <cstdio> #include < ...
随机推荐
- UOJ#31 【UR #2】猪猪侠再战括号序列
传送门http://uoj.ac/problem/31 大家好我是来自百度贴吧的_叫我猪猪侠,英文名叫_CallMeGGBond. 我不曾上过大学,但这不影响我对离散数学.复杂性分析等领域的兴趣:尤其 ...
- bzoj 1054 bfs
就是bfs,对于每个状态存一个hash为当前状态矩阵的二进制表示,然后搜就行了,写成双向bfs会快很多. 反思:对于C++的数组从0开始还不是特别习惯,经常犯错,对于C++的结构体不熟. /***** ...
- 更改控件中DrawableLeft图片的大小,图片与文字的距离
Drawable drawable=getResources().getDrawable(R.drawable.xx); //获取图片 drawable.setBounds(left, top, ri ...
- cart回归树算法过程
回归树:使用平方误差最小准则 训练集为:D={(x1,y1), (x2,y2), …, (xn,yn)}. 输出Y为连续变量,将输入划分为M个区域,分别为R1,R2,…,RM,每个区域的输出值分别为: ...
- Linux网络编程之套接字基础
1.套接字的基本结构 struct sockaddr 这个结构用来存储套接字地址. 数据定义: struct sockaddr { unsigned short sa_family; /* addre ...
- dev_cpu_dead
Kernel: 4.12.6 每个cpu都有自己的softnet_data结构,用来处理数据包接收,但是当softnet_data所在cpu无法工作时,即CPUHP_NET_DEV_DEAD状态,就需 ...
- python基础===利用PyCharm进行Python远程调试(转)
原文链接:利用PyCharm进行Python远程调试 背景描述 有时候Python应用的代码在本地开发环境运行十分正常,但是放到线上以后却出现了莫名其妙的异常,经过再三排查以后还是找不到问题原因,于是 ...
- 64_f1
FUR-0.4.6-13.fc26.x86_64.rpm 13-Feb-2017 23:32 45882 Falcon-0.9.6.8-11.fc26.i686.rpm 13-Feb-2017 23: ...
- 自己动手一步步安装Linux系统
自己动手一步步安装Linux系统 http://502245466.blog.51cto.com/7559397/1291910/
- FIS3 大白话【一】
1.fis3可以用fis.set进行一些全局的配置,包括忽略文件.文件后缀处理类型.源码过滤等等,用fis3.get可以得到配置信息,详见: http://fis.baidu.com/fis3/doc ...