参考:https://blog.csdn.net/sr_19930829/article/details/38108871

 #include <iostream>
#include <string.h>
using namespace std;
int c,n;//c种颜色,n个珠子
int ans; int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
} int power(int p,int n)//快速幂求公式里的k的nc(g)次方
{
int ans=;
while(n)
{
if(n&)
ans*=p;
p*=p;
n/=;
}
return ans;
} int main()
{
while(cin>>c>>n&&(c||n))
{
ans=;
for(int i=;i<=n;i++)
ans+=power(c,gcd(n,i));//相当于求图3-1中左边的循环群染色数
if(n&)//是奇数,有n个包含(n/2+1)个循环节的循环群
ans+=n*power(c,n/+);
else
ans+=(power(c,n/+)+power(c,n/))*(n/);
ans/=*n;//别忘了除以置换群的总个数
cout<<ans<<endl;
}
return ;
}

[ACM] POJ 2409 Let it Bead (Polya计数)的更多相关文章

  1. poj 2409 Let it Bead Polya计数

    旋转能够分为n种置换,相应的循环个数各自是gcd(n,i),个i=0时不动,有n个 翻转分为奇偶讨论,奇数时有n种置换,每种有n/2+1个 偶数时有n种置换,一半是n/2+1个,一半是n/2个 啃论文 ...

  2. POJ 2409 Let it Bead(polay计数)

    题目链接:http://poj.org/problem?id=2409 题意:给出一个长度为m的项链,每个珠子可以用n种颜色涂色.翻转和旋转后相同的算作一种.有多少种不同的项链? 思路: (1) 对于 ...

  3. POJ 2409 Let it Bead (Polya定理)

    题意 用k种颜色对n个珠子构成的环上色,旋转翻转后相同的只算一种,求不等价的着色方案数. 思路 Polya定理 X是对象集合{1, 2, --, n}, 设G是X上的置换群,用M种颜色染N种对象,则不 ...

  4. poj 1286 Necklace of Beads &amp; poj 2409 Let it Bead(初涉polya定理)

    http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...

  5. bzoj 1004 [HNOI2008]Cards && poj 2409 Let it Bead ——置换群

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004 http://poj.org/problem?id=2409 学习材料:https:/ ...

  6. poj 1286 Necklace of Beads poj 2409 Let it Bead HDU 3923 Invoker <组合数学>

    链接:http://poj.org/problem?id=1286 http://poj.org/problem?id=2409 #include <cstdio> #include &l ...

  7. POJ 2409 Let it Bead(polya裸题)

    题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...

  8. poj 2409 Let it Bead && poj 1286 Necklace of Beads(Polya定理)

    题目:http://poj.org/problem?id=2409 题意:用k种不同的颜色给长度为n的项链染色 网上大神的题解: 1.旋转置换:一个有n个旋转置换,依次为旋转0,1,2,```n-1. ...

  9. POJ 2409 Let it Bead:置换群 Polya定理

    题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...

随机推荐

  1. DataBase Migration 使用笔记

    Add-Migration 新建数据库迁移版本 Update-Database -Verbose 更新到数据库(-Verbose 显示详细信息) Update-Database –TargetMigr ...

  2. 3.Zabbix 3.0 部署

    请查看我的有道云笔记: http://note.youdao.com/noteshare?id=0139b8d2833129740be82e36a94e4fca&sub=5931260FCC8 ...

  3. vue v-on:事件

    1.js代码 var box=new Vue({ el:'.box', data:{ msg:'hello' }, methods:{ /*方法放置区,函数*/ show:function(){ // ...

  4. Orchard core 中文文档翻译系列

    本系列翻译顺序完全参照 官方顺序 原文地址:https://orchardcore.readthedocs.io/en/latest/ Orchard Core 中文文档翻译(一)关于Orchard ...

  5. CSS实战3

    1. z-index  层级   div 层 <!DOCTYPE html> <html> <head lang="en"> <meta ...

  6. Java集合框架之Set接口

     1.Set接口不记录元素添加顺序的误区 public  void setDemo(){        Set<String> set1 = new HashSet<>();  ...

  7. Spring技术内幕阅读笔记(一)

    1.BeanFactory:实现ioc容器的最基本形式.String FACTORY_BEAN_PREFIX = "&";Object getBean(String var ...

  8. Linux mongodb安装、启动、运行

    1.下载     wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.4.tgz     2.安装     tar -zxvf  ...

  9. UML绘制活动图--客户来电咨询活动图

    选择Logic View–>New–>Activity Diagram 修改NewActivity为客户来电咨询 选择初始状态和终止状态(下图中上面是Start State,下面是End ...

  10. poj 1236 Network of Schools : 求需要添加多少条边成为强连通图 tarjan O(E)

    /** problem: http://poj.org/problem?id=1236 缩点后入度为0的点的总数为需要发放软件的学校个数 缩点后出度为0的点的总数和入度为0的点的总数的最大值为需要增加 ...