Let it Bead

大意:给你m种颜色,n个珠子串起来。旋转跟反转同样算同样,问有多少种不同的涂色组合方式。

思路:Polya的简单应用。

/*************************************************************************
> File Name: POJ2409.cpp
> Author: GLSilence
> Created Time: 2014年07月29日 星期二 22时56分58秒
************************************************************************/ #include<stdio.h>
#include<iostream>
#include <math.h>
using namespace std; #define LL long long LL GCD(LL a, LL b){
return b ? GCD(b, a%b) : a;
} int n, m; int main()
{
while(~scanf("%d%d", &m, &n) && (n||m)){
LL ans = 0; for(int i = 1; i <= n; ++i){
ans += (LL)pow(m*1.0, GCD(n, i));
} if(n%2){
ans += n*(LL)pow(m*1.0, n/2+1);
}
else {
ans += n/2*(LL)pow(m*1.0, n/2);
ans += n/2*(LL)pow(m*1.0, n/2+1);
} printf("%lld\n", ans/2/n); } return 0;
}

POJ 2409 Let it Bead(Polya简单应用)的更多相关文章

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

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

  2. poj 2409 Let it Bead Polya计数

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

  3. [ACM] POJ 2409 Let it Bead (Polya计数)

    参考:https://blog.csdn.net/sr_19930829/article/details/38108871 #include <iostream> #include < ...

  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. 解决myeclipse不编译的方法

    请按照下面方法对号入座: MyEclipse不编译解决1. 确保 project->build automatically 已经被选上(最基本). MyEclipse不编译解决2. 如果选上了, ...

  2. TSynAuthentication SESSION验证

    TSynAuthentication SESSION验证 服务端维护的SESSIONS,实质上是一个array of integer,保存的是客户端的SESSIONID. SESSIONID可以由客户 ...

  3. JavaMail入门:创建纯文本、HTML格式的邮件

    转自:http://haolloyin.blog.51cto.com/1177454/353849/ 在 http://java.sun.com/products/javamail/ 下载了 Java ...

  4. meteor学习-- #一 安装meteor快速使用

    下载安装 curl https://install.meteor.com/ | sh meteor会自动下载mongodb和其他需要依赖的库,不需要手动安装. 如果是Windows 的用户,请使用 m ...

  5. easyui-textbox input输入框的一种取值方式

    1.html文件 <td> <input id="clientPhone" type="text" name="clientPhon ...

  6. [转]How to solve SSIS error code 0xC020801C/0xC004700C/0xC0047017

    本文转自:http://www.codeproject.com/Articles/534651/HowplustoplussolveplusSSISpluserrorpluscodeplus0xC B ...

  7. Razor语法(四)

    1. @代表开始一个Razor代码块,Razor会自动匹配代码中的花括号,比如@if(p.Active){<li>@p.Name</li>} 2. @{code}标识一个Raz ...

  8. SSMybatis整合 --详细解读Mybatis对oracle数据库进行增删改查(一)

    Mybatis是现在主流的持久化层框架,与Hibernate不同的是,它鼓励程序员使用原声SQL语句对数据库进行操作.因此提供了非常灵活的功能.特别是当数据库同时访问数过多,需要进行优化时,使用sql ...

  9. 使用jstack和TDA进行java线程dump分析

    转载:http://blog.csdn.net/everlasting_188/article/details/51943095 1.jstack重点关注 命令行:jstack [-l][F] pid ...

  10. JavaScript,JS如何控制input输入字符限制

    ENTER键可以让光标移到下一个输入框 <input onkeydown="if(event.keyCode==13)event.keyCode=9" > 只能是中文& ...