POJ 1286 Necklace of Beads ——Burnside
【题目分析】
题目大意:一个环有n个点,共染三种颜色。问 在旋转和对称的情况下有多少种本质不同的方案数。
Burnside直接做。
【代码】
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; #define ll long long
#define F(i,j,k) for (int i=j;i<=k;++i) ll f[25],pow[30];
int n; int gcd(int a,int b)
{return b==0?a:gcd(b,a%b);} int main()
{
f[0]=0;pow[0]=1;
F(i,1,23) pow[i]=pow[i-1]*3;
F(z,1,23)
{
F(i,0,z-1) f[z]+=pow[gcd(i,z)];
if (z&1) f[z]+=z*pow[z/2+1];
else f[z]+=z/2*pow[z/2],f[z]+=z/2*pow[z/2+1];
f[z]/=2*z;
}
while (scanf("%d",&n)&&n>=0)
printf("%lld\n",f[n]);
}
POJ 1286 Necklace of Beads ——Burnside的更多相关文章
- 数学计数原理(Pólya):POJ 1286 Necklace of Beads
Necklace of Beads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7763 Accepted: 3247 ...
- POJ 1286 Necklace of Beads(项链的珠子)
Necklace of Beads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7874 Accepted: 3290 ...
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...
- POJ 1286 Necklace of Beads(Polya简单应用)
Necklace of Beads 大意:3种颜色的珠子,n个串在一起,旋转变换跟反转变换假设同样就算是同一种,问会有多少种不同的组合. 思路:正规学Polya的第一道题,在楠神的带领下,理解的还算挺 ...
- 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 1286 Necklace of Beads【polya定理+burnside引理】
和poj 2409差不多,就是k变成3了,详见 还有不一样的地方是记得特判n==0的情况不然会RE #include<iostream> #include<cstdio> us ...
- POJ 1286 Necklace of Beads(Polya原理)
Description Beads of red, blue or green colors are connected together into a circular necklace of n ...
- 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 1286 Necklace of Beads (polya(旋转+翻转)+模板)
Description Beads of red, blue or green colors are connected together into a circular necklace of ...
随机推荐
- 【排序】插入排序:最稳定:时间复杂度O(n^2)
想象着自己在玩扑克的时候抓牌,每抓到一张牌,按照从小到大的顺序排序. 如果第二张的点数小于第一张,就交换这两张牌,默认每次抓牌之前,前面的已经排好序了. 再来一张牌,与第二张比较,如果小于第二张,交换 ...
- (转)VIM 一键自动添加文件头注释
通过修改VIM的配置文件.vimrc可以让Vim(gvim)支持自动添加作者信息,具体代码如下: "进行版权声明的设置 "添加或更新头 map <F4> :call T ...
- UIButton Making the hit area larger
http://stackoverflow.com/questions/808503/uibutton-making-the-hit-area-larger-than-the-default-hit-a ...
- QSting, QChar, char等的转换
1,QChar 转换char: char QChar::toLatin1();char QChar::toAscii(); 2,Char转QChar: QChar(char ch); 3,QStrin ...
- 在行列都排好序的矩阵中找数 【题目】 给定一个有N*M的整型矩阵matrix和一个整数K, matrix的每一行和每一 列都是排好序的。实现一个函数,判断K 是否在matrix中。 例如: 0 1 2 5 2 3 4 7 4 4 4 8 5 7 7 9 如果K为7,返回true;如果K为6,返 回false。 【要求】 时间复杂度为O(N+M),额外空间复杂度为O(1)。
从对角考虑 package my_basic.class_3; /** * 从对角开始 */ public class Code_09_FindNumInSortedMatrix { public s ...
- Hibernate 多表查询 - Criteria添加子字段查询条件 - 出错问题解决
Criteria 查询条件如果是子对象中的非主键字段会报 could not resolve property private Criteria getCriteria(Favorite favori ...
- prototype中的ajax异步加载
jquery前台处理: var param = {a:a}; $.post("*.do",param,function(data) { var columHtml = " ...
- 674. Longest Continuous Increasing Subsequence@python
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (s ...
- dom事件机制系列
JS事件流机制 一个完整的JS事件流是从window开始,最后回到window的一个过程,事件流被分为三个阶段: (1~5)捕获过程.(5~6)目标过程.(6~10)冒泡过程. 通过addEventL ...
- Maven项目:@Override is not allowed when implement interface method
今天新建一个maven项目实现接口方法的时候报错编译不通过@Override is not allowed when implement interface method,要配置pom文件的compi ...