参考: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. 在浏览器里使用SAPGUI里的SE80

    效果如图:点击Fiori launchpad的SE80对应的tile: 即可在浏览器里打开SE80 具体步骤 (1). 在后台找到Fiori catalog page ID: SAP_FIORI_EX ...

  2. listview加载显示图片

    public class ImageAndTextListAdapter extends ArrayAdapter<ImageAndText> { private ListView lis ...

  3. POJ 1470 Closest Common Ancestors 【LCA】

    任意门:http://poj.org/problem?id=1470 Closest Common Ancestors Time Limit: 2000MS   Memory Limit: 10000 ...

  4. Class<T>和Class<?>区别

    Class<T>在实例化的时候,T要替换成具体类Class<?>它是个通配泛型,?可以代表任何类型

  5. 【转】Uint8Array 转为 string,解决中文乱码

    来源: <http://stackoverflow.com/questions/8936984/uint8array-to-string-in-javascript/22373197> / ...

  6. 【转】scp命令详解

    先说下常用的情况: 两台机器IP分别为:A.104.238.161.75,B.43.224.34.73. 在A服务器上操作,将B服务器上/home/lk/目录下所有的文件全部复制到本地的/root目录 ...

  7. Win7系统中哪些服务可以关闭?

    Win7系统中很多服务和进程其实大家在平时都用不上,这些服务和进程不仅占用了很大部分的资源,而且还会影响系统的运行速度和安全.我们可以关闭那些不常用的服务和进程来加快系统运行速度,但对于一般的用户来说 ...

  8. 【luogu P1082 同余方程】 题解

    最近一直在学习数论,讲得很快,害怕落实的不好,所以做一道luogu的同余方程练练手. 关于x的同余方程 ax ≡ 1 mod m 那么x其实就是求a关于m的乘法逆元 ax + my = 1 对于这个不 ...

  9. 轻量ORM-SqlRepoEx 重大升级

    .Net平台下兼容.NET Standard 2.0,一个实现以Lambda表达式转转换标准SQL语句,支持MySQL.SQL Server数据库方言,使用强类型操作数据的轻量级ORM工具,在减少魔法 ...

  10. NPOI操作excel(通过获取批注信息给excel动态赋值)

    private string fileName = null; //文件名 private IWorkbook workbook = null; private FileStream fs = nul ...