【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 < ...
随机推荐
- 【比赛】STSRM 09
第一题 题意:n个点,每个点坐标pi属性ai,从右往左将遇到的点向左ai范围内的点消除,后继续扫描. 现可以在扫描开始前提前消除从右往左任意点,问最少消除数(提前+扫描). n,pi,ai<=1 ...
- 继承自UITableView的类自带tableView属性,不需要在创建该属性,因为父类UITableView已经创建.
继承自UITableView的类自带tableView属性,不需要在创建该属性,因为父类UITableView已经创建. https://www.evernote.com/shard/s227 ...
- Spring总结以及在面试中的一些问题(山东数漫江湖)
1.谈谈你对spring IOC和DI的理解,它们有什么区别? IoC Inverse of Control 反转控制的概念,就是将原本在程序中手动创建UserService对象的控制权,交由Spri ...
- Nodejs mac版安装
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven ...
- mybatis 显示 sql日志
#项目日志logging.level.com.zhang.com=debug #mybatis sql相关日志显示logging.level.org.mybatis.spring=DEBUGloggi ...
- vue路由-编程式导航
除了使用 <router-link> 创建 a 标签来定义导航链接,我们还可以借助 router 的实例方法,通过编写代码来实现. router.push(location, onComp ...
- 在Linux中使用C语言实现控制流保护(CFG)【转】
转自:http://www.codesec.net/view/537311.html 一.前言 最近版本的windows有一个新的缓解措施叫做控制流保护(CFG).在一个非直接调用之前――例如,函数指 ...
- python基础===Character string
本文转自:python之Character string 1.python字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串,l Python不支持单 ...
- web前端教程:用 CSS 实现三角形与平行四边形
最近在逛某个技术网站的时候,感觉文章关键词上的样式好酷炫啊,分页的样式.来张截图: 你在首页的底部也可以看到这样一个分页栏:是不是看上去还不错?下面就来看看这是如何实现的吧~ 第一种方法:利用bord ...
- 微信小程序验证码获取倒计时
wxml <button disabled='{{disabled}}' bindtap="goGetCode">{{code}}</button> js ...