poj 2409 Let it Bead
来源:互联网 发布:淘宝二手苹果ipad 编辑:程序博客网 时间:2024/06/18 18:39
题意:
• ⽤ m 种颜⾊给⼀个有 n 个珠⼦的项链染色
• 考虑旋转、翻转同构,求⽅案数
【分析】
polya计数法…第一题。
并不会证明…
1.考虑旋转同构,那么n个珠子的项链总共n种旋转置换,对于旋转i个珠子的置换,循环节个数为gcd(n,i),至于为什么大家可以画个图出来感性理解一下…
2.考虑翻转同构,对于n为奇数,翻转对称轴必定经过其中一个珠子,所以总共有n种相同情况,每种情况循环节有(n+1)/2个。对于n为偶数,有n/2个翻转对称轴经过珠子,有n/2个不经过珠子,循环节个数分别为n/2+1和n/2个…
然后暴力求解即可。
【代码】
//poj 2409 Let it Bead#include<cmath>#include<cstdio>#include<cstring>#include<iostream>#define ll long long#define M(a) memset(a,0,sizeof a)#define fo(i,j,k) for(i=j;i<=k;i++)using namespace std;ll ans;int n,m;inline int gcd(int x,int y){ return x%y==0?y:gcd(y,x%y);}int main(){ int i,j; while(scanf("%d%d",&m,&n)) { if(!n && !m) return 0; ans=0; fo(i,1,n) ans+=pow(m,gcd(n,i)); if(n&1) ans+=n*pow(m,(n+1)/2); else ans+=n/2*pow(m,n/2+1)+n/2*pow(m,n/2); printf("%lld\n",ans/n/2); }}//but the world keeps spinning around.
0 0
- poj 2409 【Let it Bead】
- poj 2409 Let it Bead
- POJ 2409 Let it Bead
- poj 2409 Let it Bead
- POJ 2409 Let it Bead
- poj-2409 Let it Bead
- POJ 2409 Let it Bead
- poj 2409 Let it Bead
- POJ 2409 Let it Bead
- Let it Bead (POJ
- Let it Bead POJ
- poj 2409 Let it Bead //poly
- POJ 2409 Let it Bead 组合数学
- 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 (polya)
- Python格式化字符串
- Problem B: 平面上的点和线——Point类、Line类 (II)
- mac 下配置 svn 开机自启动
- CCF NOI1052 Self-Numbers
- Linux网络编程学习笔记--socket编程4--7
- poj 2409 Let it Bead
- JDBC
- 事件(认识事件,重写event(),事件过滤器,定时器,事件总结)
- Spring Boot Servlet配置
- 多条目加载--->(如:新闻的布局)
- java——二叉查找树(BST)算法
- 网站商品信息爬虫代码及详细注释
- Problem C: 平面上的点和线——Point类、Line类 (III)
- Android 多状态加载布局的开发 Tips