poj1286 Necklace of Beads【裸polya】】的更多相关文章

Necklace of Beads 大意:3种颜色的珠子,n个串在一起,旋转变换跟反转变换假设同样就算是同一种,问会有多少种不同的组合. 思路:正规学Polya的第一道题,在楠神的带领下,理解的还算挺快的.代码没什么好说的,裸的Polya.也不须要优化. /************************************************************************* > File Name: POJ1286.cpp > Author: GLSilence &…
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…
非常裸的polya,只是我看polya看了非常久 吉大ACM模板里面也有 #include <cstdio> #include <cmath> #include <iostream> using namespace std; long long gcd(long long a,long long b) { return b==0?a:gcd(b,a%b); } int main() { #ifndef ONLINE_JUDGE //freopen("G:/1.…
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…
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…
题目: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;…
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…
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…
Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8263   Accepted: 3452 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://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个置…
点我看题目 题意 :给你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; }…
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…
Necklace of Beads Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1817 Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 40 ). If…
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…
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…
  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…
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;…
这是做的第一道群论题,自然要很水又很裸.注意用long long. 就是用到了两个定理 burnside :不等价方案数=每个置换的不动置换方案数的和 / 置换个数 polya: 一个置换的不动置换方案数=k^(这个置换的循环个数) 先看第一个博客再看第二个 http://cxjyxx.me/?p=198 http://endlesscount.blog.163.com/blog/static/82119787201221324524202/ 这两个蛮好的,上代码: #include <cstd…
http://poj.org/problem?id=1286 // File Name: poj1286.cpp // Author: bo_jwolf // Created Time: 2013年10月07日 星期一 21:31:08 #include<vector> #include<list> #include<map> #include<set> #include<deque> #include<stack> #include…
参考了http://blog.csdn.net/ACM_cxlove?viewmode=contents           by---cxlove 的模板 对于每一种染色,都有一个等价群,例如旋转,翻转等.我们将每一种变换转换成一个置换群,通过置换群得到的都是等价的染色方案 最终我们要求的是非等价的染色方案数. 在Burnside定理中给出,在每一种置换群也就是等价群中的数量和除以置换群的数量,即非等价的着色数等于在置换群中的置换作用下保持不变的着色平均数. 我们以POJ 2409 Let i…
链接: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 ) {…
题解 群论,我们只要找出所有的置换群的所有循环节 具体可参照算法艺术与信息学竞赛 旋转的置换有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…
\(\color{#0066ff}{ 题目描述 }\) 一个圈上有n个珠子,有三种颜色可以染,问本质不同的方案数(通过旋转和翻转重合的算一种) \(\color{#0066ff}{输入格式}\) 多组数据,每次一个n,以-1结束 \(\color{#0066ff}{输出格式}\) 每组数据输出一行一个数表示方案数 \(\color{#0066ff}{输入样例}\) 4 5 -1 \(\color{#0066ff}{输出样例}\) 21 39 \(\color{#0066ff}{数据范围与提示}\…
[题目分析] 题目大意:一个环有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;++…
由于这是第一天去实现polya题,所以由易到难,先来个铺垫题(假设读者是看过课件的,不然可能会对有些“显然”的地方会看不懂): 一:POJ1286 Necklace of Beads :有三种颜色,问可以翻转,可以旋转的染色方案数,n<24. 1,n比较小,恶意的揣测出题人很有可能出超级多组数据,所以先打表. 2,考虑旋转: ;i<n;i++) sum+=pow(n,gcd(n,i)); 3,考虑翻转: ) sum+=n*pow(,n/+) ; else { sum+=n/*pow(,n/)…
Let it Bead Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5365   Accepted: 3585 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 b…
POJ 2409 Let it Bead 这题就是polya公式的直接套用,唯一麻烦的是置换群的种类数,由于可以翻转,所以除了要加上pow(c,gcd(s,i))这些平面旋转的置换群,还要加上翻转的.由于翻转的情况奇偶是不同的,所以需要分开讨论:偶数:pow(c,(s-2)/2+2)*(s/2)+pow(c,(s/2))*(s/2);(里面包含了两个对点和两个对边的旋转) 奇数:pow(c,(s-1)/2+1)*s;(一个点和对边的旋转) #include<iostream> #include…