Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < ). If the repetitions that are produced by rotation around the center of the circular necklace or reflection to the axis of symmetry are…
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜了一篇论文Pólya原理及其应用看了看polya究竟是什么东东.它主要计算所有互异的组合的个数.对置换群还是似懂略懂.用polya定理解决这个问题的关键是找出置换群的个数及哪些置换群,每种置换的循环节数.像这样的不同颜色的珠子构成项链的问题能够把N个珠子看成正N边形. Polya定理:(1)设G是p…
Necklace of Beads 大意:3种颜色的珠子,n个串在一起,旋转变换跟反转变换假设同样就算是同一种,问会有多少种不同的组合. 思路:正规学Polya的第一道题,在楠神的带领下,理解的还算挺快的.代码没什么好说的,裸的Polya.也不须要优化. /************************************************************************* > File Name: POJ1286.cpp > Author: GLSilence &…
Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7874   Accepted: 3290 Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are pro…
链接:http://poj.org/problem?id=1286 http://poj.org/problem?id=2409 #include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <algorithm> using namespace std; typedef long long LL; LL P_M( LL a, LL b ) {…
Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7763   Accepted: 3247 Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are pro…
题目:http://poj.org/problem?id=2409 题意:用k种不同的颜色给长度为n的项链染色 网上大神的题解: 1.旋转置换:一个有n个旋转置换,依次为旋转0,1,2,```n-1.对每一个旋转置换,它循环分解之后得到的循环因子个数为gcd(n,i). 2.翻转置换:分奇偶讨论. 奇数的时候 翻转轴 = (顶点+对边终点的连线),一共有n个顶点,故有n个置换,且每个置换分解之后的因子个数为n/2+1; 偶数的时候 翻转轴 = (顶点+顶点的连线),一共有n个顶点,故有n/2个置…
Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are produced by rotation around the center of the circular necklace or reflection to the axis of symmetry ar…
点我看题目 题意 :给你3个颜色的n个珠子,能组成多少不同形式的项链. 思路 :这个题分类就是polya定理,这个定理看起来真的是很麻烦啊T_T.......看了有个人写的不错: Polya定理: (1)设G是p个对象的一个置换群,用k种颜色突然这p个对象,若一种染色方案在群G的作用下变为另一种方案,则这 两个方案当作是同一种方案,这样的不同染色方案数为: : (2)置换及循环节数的计算方法:对于有n个位置的手镯,有n种旋转置换和n种翻转置换.对于旋转置换: c(fi) = gcd(n,i) …
和poj 2409差不多,就是k变成3了,详见 还有不一样的地方是记得特判n==0的情况不然会RE #include<iostream> #include<cstdio> using namespace std; long long n,ans; long long ksm(long long a,long long b) { long long r=1; while(b) { if(b&1) r=r*a; a=a*a; b>>=1; } return r; }…
这是做的第一道群论题,自然要很水又很裸.注意用long long. 就是用到了两个定理 burnside :不等价方案数=每个置换的不动置换方案数的和 / 置换个数 polya: 一个置换的不动置换方案数=k^(这个置换的循环个数) 先看第一个博客再看第二个 http://cxjyxx.me/?p=198 http://endlesscount.blog.163.com/blog/static/82119787201221324524202/ 这两个蛮好的,上代码: #include <cstd…
[题目分析] 题目大意:一个环有n个点,共染三种颜色.问 在旋转和对称的情况下有多少种本质不同的方案数. Burnside直接做. [代码] #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define ll long long #define F(i,j,k) for (int i=j;i<=k;++…
Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7451   Accepted: 3102 Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are pro…
Necklace of Beads Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1049    Accepted Submission(s): 378 Problem Description Beads of red, blue or green colors are connected together into a circula…
题解 群论,我们只要找出所有的置换群的所有循环节 具体可参照算法艺术与信息学竞赛 旋转的置换有n个,每一个的循环节个数是gcd(N,i),i的范围是0到N - 1 翻转,对于奇数来说固定一个点,然后剩下的交换,循环节个数是(N - 1)/2 +1 对于偶数来说,不经过球的有N/2个,循环节个数是(N / 2) 经过球也也有N/2,循环节个数是(N / 2) + 1 代码 #include <iostream> #include <cstdio> #include <vecto…
题目:http://poj.org/problem?id=1286 真·Polya定理模板题: 写完以后感觉理解更深刻了呢. 代码如下: #include<iostream> #include<cstdio> #include<cstring> using namespace std; typedef long long ll; int n; ll ans; ll pw(ll a,int b) { ll ret=; ,a*=a) )ret*=a; return ret;…
http://poj.org/problem?id=1286 题意:求用3种颜色给n个珠子涂色的方案数.polya定理模板题. #include <stdio.h> #include <math.h> long long gcd(long long a,long long b) { return b?gcd(b,a%b):a; } int main() { long long n; while(~scanf("%lld",&n)) { ) break;…
Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9359   Accepted: 3862 Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are produced by rotation…
题目链接:http://vjudge.net/problem/viewProblem.action?id=11117 就是利用每种等价情形算出置换节之后算组合数 #include <stdio.h> #include <cstring> #include <cstdlib> #include <algorithm> #include <cmath> using namespace std; #define lson o<<1 #def…
\(\color{#0066ff}{ 题目描述 }\) 一个圈上有n个珠子,有三种颜色可以染,问本质不同的方案数(通过旋转和翻转重合的算一种) \(\color{#0066ff}{输入格式}\) 多组数据,每次一个n,以-1结束 \(\color{#0066ff}{输出格式}\) 每组数据输出一行一个数表示方案数 \(\color{#0066ff}{输入样例}\) 4 5 -1 \(\color{#0066ff}{输出样例}\) 21 39 \(\color{#0066ff}{数据范围与提示}\…
Necklace of Beads Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 630    Accepted Submission(s): 232 Problem Description Beads of red, blue or green colors are connected together into a circular…
Necklace of Beads Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are produced by rotation around the center of the circular necklace or reflection to the a…
Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9162   Accepted: 3786 Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are pro…
题意 用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种翻转,每种翻转的轴都是一个顶点和该顶点对边…
NOI题库开始的题,也是略水,当然也是大水,所以彼此彼此 09:图像旋转翻转变换 总时间限制: 1000ms 内存限制: 65536kB 描述 给定m行n列的图像各像素点灰度值,对其依次进行一系列操作后,求最终图像. 其中,可能的操作及对应字符有如下四种: A:顺时针旋转90度: B:逆时针旋转90度: C:左右翻转: D:上下翻转. 输入 第一行包含两个正整数m和n,表示图像的行数和列数,中间用单个空格隔开.1 <= m <= 100, 1 <= n <= 100. 接下来m行,…
Excel 二维数组(数据块)旋转/翻转技巧 原创 2017-12-30 久石六 久石六 工作中遇到个问题,需要将Excel中的数据块或者说二维数组向右旋转90度,才能再加工处理.当然,不是旋转文本方向,那太容易了,而是整体旋转改变数据块的排列组合顺序.如下所示: 这个问题如果换成是图形,那也很容易,在“格式”菜单下有旋转功能可选,可是数据块怎么旋?问问度娘,似乎只给出了一种解决方案,就是利用 Offset 函数,这个亲测也确实有效,视为第一种方法吧,可是自己经常要做这样的旋转,不停地码公式也是…
题意: 给你三种颜色的珠子,每次给你N,问在旋转,翻转之后视作相同的情况下,能组成多少种不同的项链. 思路: 让我们借这道题拯救一下我对POLYA定理的理解... sigma(m^(gcd(i,n))) 以上是在旋转的时候计数的和,其中m是颜色的数量,n是项链的长度. 一下考虑翻转的情况: 当n是偶数的时候, 有n/2种情况循环节的数量是n/2+1,有n/2种情况是n/2. 当n是奇数的时候, 有n种情况是循环节的数量是n/2+1 别忘了最后要除以循环节总的种类数!!! 坑点: 这题n可能等于0…
Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are produced by rotation around the center of the circular necklace or reflection to the axis of symmetry are all neglec…
Polya定理:设G={π1,π2,π3........πn}是X={a1,a2,a3.......an}上一个置换群,用m中颜色对X中的元素进行涂色,那么不同的涂色方案数为:1/|G|*(mC(π1)+mC(π2)+mC(π3)+...+mC(πk)). 其中C(πk)为置换πk的循环节的个数. Polya定理的基础应用. 你得算出旋转和翻转时,每种置换的循环节数. 旋转时,每种置换的循环节数为gcd(n,i): 翻转时,若n为奇数,共有n个循环节数为n+1>>1的置换, 若n为偶数,共有n…
#include <iostream> #include <math.h> using namespace std; #define LL long long LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; } LL polya(LL n) { LL ret = ; ; i < n; i++) ret += pow(, gcd(i, n)); //flip them... )//odd ret += n * pow(, n…