POJ 2409 Let it Bead(Polya简单应用)
大意:给你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简单应用)的更多相关文章
- POJ 2409 Let it Bead (Polya定理)
题意 用k种颜色对n个珠子构成的环上色,旋转翻转后相同的只算一种,求不等价的着色方案数. 思路 Polya定理 X是对象集合{1, 2, --, n}, 设G是X上的置换群,用M种颜色染N种对象,则不 ...
- poj 2409 Let it Bead Polya计数
旋转能够分为n种置换,相应的循环个数各自是gcd(n,i),个i=0时不动,有n个 翻转分为奇偶讨论,奇数时有n种置换,每种有n/2+1个 偶数时有n种置换,一半是n/2+1个,一半是n/2个 啃论文 ...
- [ACM] POJ 2409 Let it Bead (Polya计数)
参考:https://blog.csdn.net/sr_19930829/article/details/38108871 #include <iostream> #include < ...
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...
- 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:/ ...
- 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 ...
- POJ 2409 Let it Bead(polya裸题)
题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...
- 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. ...
- POJ 2409 Let it Bead:置换群 Polya定理
题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...
随机推荐
- nginx配置rewrite总结
1.rewrite regex replacement [flag] 2.flag为break时,url重写后,直接使用当前资源,不在执行location里其他语句,完成本次请求,地址栏url不变. ...
- ECCV 2014 Oral Paper
今年的ECCV 的paper已经挂到了网上.本文整了当中Oral Paper. 一,Tracking and Activity Recognition
- QT5.11下载与安装教程
一.QT软件下载 Qt 5.9 之后的安装包与之前相比,不再区分 VS 版本和 MinGW 版本,而是全都整合到了一个安装包中.因此,与之前的安装包相比,体积也是大了不少,以前是 1G 多,现在是 2 ...
- ORA-01219:数据库未打开:仅允许在固定表/视图中查询
好久没有登陆到Oracle的服务器了,把密码都忘记了.sql>conn sys/sys as sysdba;sql>alter user system identified by *;结果 ...
- java web 拦截器、过滤器理解
1.首先要明确什么是拦截器.什么是过滤器 1.1 什么是拦截器: 拦截器,在AOP(Aspect-Oriented Programming)中用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加 ...
- 投票ajax请求代码(点赞代码)
function vote(url, arr) { jq.ajax({ cache: false, async: false, url: url, type: 'post', data: {info_ ...
- Visual studio之C#实现数字输入模拟键盘
背景 当前做的一个上位机需运行在工控机上,众所周知,工控机不可能配备键盘,只能是触屏,而我当前的上位机需要输入参数,于是之前的解决办法既是调用Windows自带的OSK.exe虚拟键盘,方法在我的另一 ...
- Mybatis <if>标签
格式:<if test=""> sql语句 </if> <select id="selectByName" resultType= ...
- SuperMap iClient如何使用WMTS地图服务
SuperMap iClient如何使用WMTS地图服务 什么是WMTS服务 WMTS,切片地图Web服务(Web Map Tile Service)当前版本是1.0.0.该服务符合 OGC(Open ...
- 【WEB】jQuery获取页面回滚或跳转事件
1.效果: 2.Jquery: //记得引入jquery.min.js <script type="text/javascript"> $(function(){ wi ...