poj 2409 polya计数
来源:互联网 发布:bp神经网络算法预测 编辑:程序博客网 时间:2024/05/18 20:09
题意:给定一串由n个珠子组成的项链,用c种颜色涂染,问能形成多少种不同项链。
思路:Burnside算法。分析:
1.旋转.
考虑顺时针旋转i格的置换:
循环个数为gcd(n,i)
每个循环的长度为L=n/gcd(n,i)
2.翻转
考虑对称轴
***n为奇数. 只有一种对称轴, 即轴穿过一个点. 有[n/2]个循环长度为2, 还有一个循环长度为1(被穿过的点), V=C([n/2], [m/2]).
***n为偶数, 有两种翻转
轴每边n/2个点. 这样的置换有n/2个
轴穿两点, 每边n/2个点. 这样的置换也有n/2个
算法复杂度分析:很容易可以算出这个算法的时间复杂度为O(n)。
#include <stdio.h>#include <string.h>#include <math.h>int m,n;int gcd(int x,int y){ if (!y) return x; return gcd(y,x%y);}int main(){ while(scanf("%d %d",&m,&n) && (m+n)){ int i; long long res = 0; for (i = 0;i<n;i++) res += pow(m,gcd(n,i)); if (n&1) res += n*pow(m,n/2+1); else res += n/2*(pow(m,n/2)+pow(m,n/2+1)); printf("%lld\n",res/n/2); } return 0;}
0 0
- poj 2409 polya计数
- poj 2409 【polya计数】
- POJ 1286 2409 Polya计数
- POj 2409 Let it Bead ----- polya计数
- poj 2409 Let it Bead Polya计数
- POJ 2409-Let it Bead(Polya计数)
- POJ 2409 Let it Bead (Polya计数)
- poj 2154 polya 计数
- POJ 1286 Necklace of Beads && POJ 2409 Polya计数原理
- poj 2154 Color ----polya计数
- poj 2154 Color( polya 计数)
- [ACM] POJ 2409 Let it Bead (Polya计数)
- POJ 2409 Let it Bead (Polya计数)
- POJ 2409 Let it Bead (polya计数)
- POJ 2409 Let it Bead (polya计数,burnside染色)
- poj 1286 Necklace of Beads -----polya计数
- poj 1286 Necklace of Beads polya计数
- poj 1286 Necklace of Beads 【polya计数】
- Hibernate(5)关联映射之多对多级联
- Linux下paste命令详解
- 在Windows下的Java与android环境配置简单方法
- hbase 系统 hbase-site.xml 配置说明
- java原子变量
- poj 2409 polya计数
- iOS 屏幕适配,autoResizing autoLayout和sizeClass图文详解
- NSString 使用(二)
- 优秀storm博客汇总
- Spring在web应用中获得Bean的方法 实现getBean方法
- 【分享教训】关于一个字母价值2000块钱的深刻教训20150120
- 一个硕士是怎样发5篇SCI的?
- Python学习:list(数组)
- HDU 2163 Palindromes