【裸polya定理】poj 2409 Let it Bead
2015-09-17 17:51
363 查看
poj 2409 Let it Bead
加粗
斜体
引用
插入链接
插入代码
插入图片
提升标题
有序列表
无序列表
横线
撤销
重做
http://poj.org/problem?id=2409
思路
polya定理经典问题:c种颜色的珠子组成长为s的项链的方案数,项链没有方向和起始位置参考代码
#include<iostream> #include<cstdio> #include<cstdlib> using namespace std; typedef long long ll; const int _max = 20 + 10; int n,c,s; ll gcd(ll a,ll b){return b ? gcd(b,a%b):a;} ll polya(int c, int s){//c种颜色去染s个珠子串成的项链 ll p[64];p[0] = 1;//power of c for(int k = 0; k < s; ++ k) p[k+1] = p[k]*c; //reflection part ll count = s&1 ? s*p[s/2+1]:(s/2)*(p[s/2]+p[s/2+1]); //rotation part for(int k = 1;k <= s; ++ k)count+=p[gcd(k,s)]; count /= 2 * s; return count; } int main(){ #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); #endif // ONLINE_JUDGE while(scanf("%d%d",&c,&s) == 2 && (s||n)){ printf("%lld\n",polya(c,s)); } return 0; }
加粗
Ctrl + B
斜体
Ctrl + I
引用
Ctrl + Q
插入链接
Ctrl + L
插入代码
Ctrl + K
插入图片
Ctrl + G
提升标题
Ctrl + H
有序列表
Ctrl + O
无序列表
Ctrl + U
横线
Ctrl + R
撤销
Ctrl + Z
重做
Ctrl + Y
相关文章推荐
- 【WIkiOI】【P2926】【黑白瓷砖】【Polya定理】【题解】
- polya定理
- poj2409 Let it Bead
- 【Polya定理】SCU 4423
- uva10294 Arif in Dhaka (First Love Part 2)
- 【POJ 2409】Let it Bead(Polay 定理)
- 【POJ 1286】Necklace of Beads(Polya 定理)
- POJ 2409 Let it Bead
- BZOJ 1478 Sgu282 Isomorphism
- hdu 5868 Different Circle Permutation Polya定理 欧拉函数优化
- poj 2154 Color Polya定理 欧拉函数优化
- poj 2409 Let it Bead Polya定理
- POJ 1286-Necklace of Beads(Polya定理-旋转+翻转 串项链)
- POJ 3270-Cow SortingA(Polya定理-交换次数)
- POJ 2154-Color(Polya定理-旋转 串项链)
- POJ 2409-Let it Bead(Polya定理-旋转+翻转 串项链)
- POJ 2154 Color (Polya定理&欧拉函数)
- 组合数学常用内容——Polya定理+Burnside引理
- UVA 10601 Cubes (Polya定理+Burnside引理)
- polya 定理总结