Let it Bead
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6443   Accepted: 4315

Description

"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 0

Sample Output

1
2
3
5
8
13
21

Source

感觉这玩意儿认真的好神奇啊qwq。

为什么网上都是直接说循环节的大小但是不做说明qwq、、

算了还是背结论吧

若是直接旋转,那么有$n$中置换,第$i$种循环节数为$gcd(n, i)$

如果是对称

对于奇数来说,可以固定一个点,让其他点交换。共有$n$个点,每种循环节为$\frac{n + 1}{2}$

对于偶数来说,有两种对称方式,

一种是以中线为中心,两边对称,共有$N / 2$种方式,每种循环节为$\frac{n + 2}{2}$

另一种是两个点的连线为中心,两边对称,共有$N/ 2$种方式,每种循环节为$\frac{n}{2}$

然后直接上polya定理就行了

POJ的评测机也是没谁了

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define LL long long
const int MAXN = 1e5 + ;
using namespace std;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int C, N;
int fastpow(int a, int p) {
int base = ;
while(p) {
if(p & ) base = base * a;
a = a * a; p >>= ;
}
return base;
}
main() {
while(scanf("%d %d", &C, &N)) {
if(C == && N == ) break;
int ans = ;
for(int i = ; i <= N; i++) ans += fastpow(C, __gcd(i, N));
if(N & ) ans = ans + N * fastpow(C, (N + ) / );
else ans = ans + N / * (fastpow(C, (N + ) / ) + fastpow(C, N / ));
printf("%d\n", ans / / N);
}
}

POJ2409 Let it Bead(Polya定理)的更多相关文章

  1. 【POJ2409】Let it Bead Pólya定理

    [POJ2409]Let it Bead 题意:用$m$种颜色去染$n$个点的环,如果两个环在旋转或翻转后是相同的,则称这两个环是同构的.求不同构的环的个数. $n,m$很小就是了. 题解:在旋转$i ...

  2. 置换群 Burnside引理 Pólya定理(Polya)

    置换群 设\(N\)表示组合方案集合.如用两种颜色染四个格子,则\(N=\{\{0,0,0,0\},\{0,0,0,1\},\{0,0,1,0\},...,\{1,1,1,1\}\}\),\(|N|= ...

  3. 【BZOJ1478】Sgu282 Isomorphism Pólya定理神题

    [BZOJ1478]Sgu282 Isomorphism 题意:用$m$种颜色去染一张$n$个点的完全图,如果一个图可以通过节点重新标号变成另外一个图,则称这两个图是相同的.问不同的染色方案数.答案对 ...

  4. 【POJ2154】Color Pólya定理+欧拉函数

    [POJ2154]Color 题意:求用$n$种颜色染$n$个珠子的项链的方案数.在旋转后相同的方案算作一种.答案对$P$取模. 询问次数$\le 3500$,$n\le 10^9,P\le 3000 ...

  5. 数学:Burnside引理与Pólya定理

    这个计数定理在考虑对称的计数中非常有用 先给出这个定理的描述,虽然看不太懂: 在一个置换群G={a1,a2,a3……ak}中,把每个置换都写成不相交循环的乘积. 设C1(ak)是在置换ak的作用下不动 ...

  6. 置换及Pólya定理

    听大佬们说了这么久Pólya定理,终于有时间把这个定理学习一下了. 置换(permutation)简单来说就是一个(全)排列,比如 \(1,2,3,4\) 的一个置换为 \(3,1,2,4\).一般地 ...

  7. Burnside引理&Pólya定理

    Burnside's lemma 引例 题目描述 一个由2*2方格组成的正方形,每个格子上可以涂色或不涂色, 问共有多少种本质不同的涂色方案. (若两种方案可通过旋转互相得到,称作本质相同的方案) 解 ...

  8. @总结 - 12@ burnside引理与pólya定理

    目录 @0 - 参考资料@ @1 - 问题引入@ @2 - burnside引理@ @3 - pólya定理@ @4 - pólya定理的生成函数形式@ @0 - 参考资料@ 博客1 @1 - 问题引 ...

  9. Pólya 定理学习笔记

    在介绍\(Polya\) 定理前,先来介绍一下群论(大概了解一下就好): 群是满足下列要求的集合: 封闭性:即有一个操作使对于这个集合中每个元素操作完都使这个集合中的元素 结合律:即对于上面那个操作有 ...

随机推荐

  1. rails4 ckeditor 的部署以及 中文化

    首先ckeditor 要基于paperclip   之后paperclip 需要你在linux 下安装  ImageMagick 具体安装可参考http://my.eoe.cn/guanmac/arc ...

  2. 执行ORACLE SQL时如何 忽略替换变量(转载)

    你想在SQL*Plus里执行一个脚本,脚本里包含了一些看起来像替换变量的元素,但实际上你并不是想把它们当替换变量来处理.这时你想让解析器忽略它们而不是提示用户输入.解决方案1有一种解决方案就是在&am ...

  3. python复习目录

    目录 一.计算机基础 二.python 2.1初始python 2.1 python基础1 2.2 python基础2 三.函数 3.1 函数进阶 3.2 函数之装饰器 3.3 递归函数之二分查找 3 ...

  4. url长度

    今天在测试Email Ticket的时候发现在进行Mark as Read/Unread操作时,请求是通过GET方式进行的.URL中列出了所有参与该操作的Ticket Id.于是,我想起GET请求是有 ...

  5. 无法找到msvcp90.dll的一个碰巧解决办法

     作者:朱金灿 来源:http://blog.csdn.net/clever101 上周同事使用VS2008编译一个C++的控制台工程.工程在release模式下可以编译成功,但是运行总是出现无法 ...

  6. TeeChart for .NET常用属性总结

    本文总结了图表控件Teechart for .NET常用的一些属性,对图表开发人员来说是一个很好的参考. 原文链接:http://blog.csdn.net/u010270772/article/de ...

  7. python 生成随机图片验证码

    1.安装pillow模块 pip install pillow (1)创建图片 from PIL import Image #定义使用Image类实例化一个长为400px,宽为400px,基于RGB的 ...

  8. 验证tensorflow版本是GPU还是CPU

    reference: https://blog.csdn.net/zlase/article/details/79261348 import numpy import tensorflow as tf ...

  9. MAC读取希捷移动硬盘ntfs

    希捷提供了mac读取ntfs磁盘的软件,Paragon. 搜索关键词 "希捷" "mac" 或者通过以下链接进入 https://www.seagate.com ...

  10. May 8th 2017 Week 19th Monday

    Art lies in concealing art. 隐而不露即艺术. Sometimes, concealing is much more seductive than totally naked ...