POj 2409 Let it Bead ----- polya计数
来源:互联网 发布:阿里云国际版账号注册 编辑:程序博客网 时间:2024/05/24 06:50
题意:给定颜色种数和环上的珠子总数,问有多少种染色方案(通过旋转和翻转相同的算同一种)。这读不出来是硬伤。。。。
两种情况讨论:
1.旋转:循环节数 GCD(N,I);
2.翻转:<1> N%2 == 1 时,N个循环节数 (N+1)/ 2 个循环群。
<2> N%2 == 0 时,N / 2 个循环节数 (N+2)/ 2 , N / 2 个循环节数 N/ 2 个循环群。
Ps:人生苦短,证明神马的就算了吧。
#include <cstdio>#include <string.h>#include <math.h>using namespace std;inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);} int main(){int n,m,ans;while(~scanf("%d%d",&m,&n),m+n){ans=0;for(int i=1;i<=n;i++){int tmp=gcd(n,i);//旋转计算循环节ans+=(int)(pow(m*1.0,tmp*1.0)); }//计算翻转的循环群 if(n&1)ans+=(int)(n*pow(m*1.0,(n+1)/2.0));else{ans+=(int)((n/2)*pow(m*1.0,(n+2)/2.0));ans+=(int)((n/2)*pow(m*1.0,n/2.0));}ans/=(2*n);printf("%d\n",ans);}return 0;}
- POj 2409 Let it Bead ----- polya计数
- poj 2409 Let it Bead Polya计数
- POJ 2409-Let it Bead(Polya计数)
- POJ 2409 Let it Bead (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 2409 Let it Bead Polya定理
- POJ 2409 Let it bead 【裸polya】
- poj 2409 Let it Bead (polya)
- POJ 2409 - Let it Bead【Polya定理】
- POJ 2409 Let it Bead ACM Polya
- POJ 2409 Let it Bead(polya)
- 【POJ 2409】 Let it Bead(Polya)
- [Polya] POJ 2409 Let it Bead
- POJ 2409 Let it Bead (Polya) .
- poj 2409 Let it Bead Polya定理
- 推荐系统开源软件列表汇总和点评
- 从一道题谈C++中构造函数调用构造函数
- android 圆角图片 处理
- IIC总线协议和硬件介绍
- 理解 ThreadLocal
- POj 2409 Let it Bead ----- polya计数
- 好饿啊
- 网页制作中CSS样式布局实用小技巧
- struts2.0 struts.xml配置详解
- 字符集校对规则collation
- Apache自动添加地址末尾的斜线
- IOS block编程注意事项
- JS实现JSP页面,鼠标禁止另存,复制,右键,选取
- python代码统计大文本文件行数