题目链接:http://vjudge.net/problem/viewProblem.action?id=11117

就是利用每种等价情形算出置换节之后算组合数

#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath> using namespace std;
#define lson o<<1
#define rson o<<1|1
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define INF 200000000 typedef long long ll;
ll qpow(ll a,int k){
ll ans=;
while(k>){
if(k&)ans*=a;
a*=a;
k>>=;
}
return ans;
}
int gcd(int a,int b){
if(a==)return b;
return gcd(b%a,a);
}
ll rotation(int n){
ll rot=;
for(int i=;i<=n;i++){
rot+=qpow(3LL,gcd(i,n));
}
return rot;
}
ll reflection(int n){
ll ref=;
if(n&){
int cir=n/+;
ref=qpow(3LL,cir)*n;
}else{
ref=(ll)(n/)*qpow(3LL,n/);
ref+=(ll)(n/)*qpow(3LL,+n/);
}
return ref;
}
int main(){
int n;
while(~scanf("%d",&n) && n+){
ll ans;
if(!n)ans=;
else ans=(rotation(n)+reflection(n))/(*n);
printf("%I64d\n",ans);
}
return ;
}

POJ 1286 Necklaces of Beads (Burnside定理,有限制型)的更多相关文章

  1. POJ 1286 Necklace of Beads ——Burnside

    [题目分析] 题目大意:一个环有n个点,共染三种颜色.问 在旋转和对称的情况下有多少种本质不同的方案数. Burnside直接做. [代码] #include <cstdio> #incl ...

  2. poj 1286 Necklace of Beads &amp; poj 2409 Let it Bead(初涉polya定理)

    http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...

  3. poj 2409+2154+2888(Burnside定理)

    三道burnside入门题: Burnside定理主要理解置换群置换后每种不动点的个数,然后n种不动点的染色数总和/n为answer. 对于旋转,旋转i个时不动点为gcd(n,i). 传送门:poj ...

  4. 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 ...

  5. poj 1286 Necklace of Beads【polya定理+burnside引理】

    和poj 2409差不多,就是k变成3了,详见 还有不一样的地方是记得特判n==0的情况不然会RE #include<iostream> #include<cstdio> us ...

  6. 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. ...

  7. POJ 1286 Necklace of Beads(Polya定理)

    点我看题目 题意 :给你3个颜色的n个珠子,能组成多少不同形式的项链. 思路 :这个题分类就是polya定理,这个定理看起来真的是很麻烦啊T_T.......看了有个人写的不错: Polya定理: ( ...

  8. poj 1286 Necklace of Beads

    这是做的第一道群论题,自然要很水又很裸.注意用long long. 就是用到了两个定理 burnside :不等价方案数=每个置换的不动置换方案数的和 / 置换个数 polya: 一个置换的不动置换方 ...

  9. poj 1286 Necklace of Beads (polya(旋转+翻转)+模板)

      Description Beads of red, blue or green colors are connected together into a circular necklace of ...

随机推荐

  1. Linux Shell编程(15)——操作字符串

    Bash已经支持了令人惊讶的字符串操作的数量.不幸地,这些工具缺乏统一的标准.一些是参数替换的子集,其它受到UNIX的expr命令的功能的影响.这导致不一致的命令语法和冗余的功能,但这些并没有引起混乱 ...

  2. 数学(概率)CodeForces 626D:Jerry's Protest

    Andrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds ...

  3. 配置Myeclipse中的项目部署到服务器,报the selected server is enabled, but is not configured properly.

    the selected server is enabled, but is not configured properly. deployment to it will not be permitt ...

  4. poj3071 Football

    学习位运算在比赛的技巧 http://poj.org/problem?id=3071 Football Time Limit: 1000MS   Memory Limit: 65536K Total ...

  5. 《A First Course in Probability》-chaper7-期望的性质-相关系数

    之前我们介绍过,协方差能够一定程度上描述两个变量之间的相关性,但是有时候它并没有那么准确,例如下面这个例子: 本质一样的两个随机变量,独立性是不变的,但是通过这个等式我看到,如果在随机变量的前面添加了 ...

  6. Android WebRTC 音视频开发总结

    www.cnblogs.com/lingyunhu/p/3621057.html 前面介绍了WebRTCDemo的基本结构,本节主要介绍WebRTC音视频服务端的处理,,转载请说明出处(博客园RTC. ...

  7. Traffic Lights - SGU 103(最短路)

    题目大意:有一个城市的路线图,有N个交叉点,每两个交叉点之间只有一条路,现在想从交点u去交点v,不过这个路的交通比较特别,每个路都有一个交通灯,灯有两种颜色,蓝色和紫色,例如一条路线在交点s,t之间, ...

  8. Musical Theme - poj 1743(求最大不重叠重复子串)

    题目大意: * 有N(1 <= N <=20000)个音符的序列来表示一首乐曲,每个音符都是1..88范围内的整数,现在要找一个重复的主题. * “主题”是整个音符序列的一个子串,它需要满 ...

  9. 一个表的两个列连接另外一个表的一个列SQL语句怎么写

    f619424517 | 浏览 2207 次 推荐于2016-09-09 11:38:18   最佳答案   select a.flightid,a.flightname,b.cityname,c.c ...

  10. 用Excel完成专业化数据统计、分析工作

    使用Excel可以完成很多专业软件才能完成的数据统计.分析工作,比如:直方图.相关系数.协方差.各种概率分布.抽样与动态模拟.总体均值判断,均值推断.线性.非线性回归.多元回归分析.时间序列等.本专题 ...