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种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...
随机推荐
- 怎样打开查看mysql binlog
1 在my.ini(window)配置文件里面 [mysqld]log-bin=mysql-bin(名字可以随便起) 我们每次进行操作的时候,File_size都会增长 2.show binlog e ...
- [Linux] ubuntu 软件安装必须看的网址
http://wiki.ubuntu.org.cn/index.php?title=Qref/Apps&variant=zh-hans 这里介绍了unbuntu常用软件及其安装,免得你百度来百 ...
- POJ 2664 Prerequisites?(简单题)
[题意简述]:k:已经选择的科目数:m:选择的科目类别:c:能够选择的科目数.r:要求最少选择的科目数量 在输入的k和m以下的一行是选择的科目号. 比如: 3 2 //3是他选择了3科.2表示选择了两 ...
- Spring MVC入门Demo
1 参考http://blog.csdn.net/haishu_zheng/article/details/51490299,用第二种方法创建一个名为springmvcdemo的Maven工程. 2 ...
- svn: warning: xxxx is already under version control
svn stat 查看当前目录下svn状态 svn remove xxxx svn add xxx svn ci -m "注释"
- Win7是否可以把光盘当作U盘用
光盘当作U盘用 在Windows 7刻录功能中,之前有看到一篇文章<Windows7 新功能 光盘当U盘用>(感兴趣的同学可以百度一下),文章的意思大致是说作者插入了一张空的DVD光盘,然 ...
- PHP #2003 - 服务器没有响应怎么办
1 出现这个问题的时候,首先可以肯定Apache服务器没有问题,因为如果Apache服务器有问题,则根本登不上phpMyadmin,如果你能登上localhost则说明Apache服务器没问题. 2 ...
- iOS UITapGestureRecognizer手势和UIButton 以及UITabelView点击事件冲突
一:在同一个view上加载,UITapGestureRecognizer手势,UIButton 行为,UITabelView点击事件冲突: 二:解决方式: 在UITapGesttureRecogniz ...
- Yahoo关于性能优化的N条军规
一. Yahoo的军规条例: 谨记:80%-90%的终端响应时间是花费在下载页面中的图片,样式表,脚本,flash等:详细的解释来这里查:http://developer.yahoo.com/perf ...
- Linux下SVN部署/安全及权限配置,实现web同步更新
转自:http://www.cnblogs.com/me115/archive/2013/04/07/3002058.html 本文包含以下内容: SVN服务器安装 SVN权限管理 SVN使用SASL ...