POJ 1286 Necklaces of Beads (Burnside定理,有限制型)
题目链接: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定理,有限制型)的更多相关文章
- POJ 1286 Necklace of Beads ——Burnside
[题目分析] 题目大意:一个环有n个点,共染三种颜色.问 在旋转和对称的情况下有多少种本质不同的方案数. Burnside直接做. [代码] #include <cstdio> #incl ...
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...
- poj 2409+2154+2888(Burnside定理)
三道burnside入门题: Burnside定理主要理解置换群置换后每种不动点的个数,然后n种不动点的染色数总和/n为answer. 对于旋转,旋转i个时不动点为gcd(n,i). 传送门:poj ...
- 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 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定理)
点我看题目 题意 :给你3个颜色的n个珠子,能组成多少不同形式的项链. 思路 :这个题分类就是polya定理,这个定理看起来真的是很麻烦啊T_T.......看了有个人写的不错: Polya定理: ( ...
- poj 1286 Necklace of Beads
这是做的第一道群论题,自然要很水又很裸.注意用long long. 就是用到了两个定理 burnside :不等价方案数=每个置换的不动置换方案数的和 / 置换个数 polya: 一个置换的不动置换方 ...
- poj 1286 Necklace of Beads (polya(旋转+翻转)+模板)
Description Beads of red, blue or green colors are connected together into a circular necklace of ...
随机推荐
- Node.js权威指南 (2) - Node.js中的交互式运行环境——REPL
2.1 REPL运行环境概述 / 102.2 在REPL运行环境中操作变量 / 102.3 在REPL运行环境中使用下划线字符 / 122.4 在REPL运行环境中直接运行函数 / 122.5 在RE ...
- codeforce --- 340D
D. Bubble Sort Graph time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Poj 3468-A Simple Problem with Integers 线段树,树状数组
题目:http://poj.org/problem?id=3468 A Simple Problem with Integers Time Limit: 5000MS Memory Limit ...
- 局域网内linux由ip反解析主机名
- Google辅助类软件
本博文的主要内容有 .Google辅助类软件的介绍 .重点首推! Google软件精选管理器 1.Google辅助类软件的介绍 1. Google软件精选管理器的下载和安装使用 2. Googl ...
- hdoj 1061 Rightmost Digit【快速幂求模】
Rightmost Digit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- MyEclipe10中集成Tomcat7
1.MyEclipse|Servers|Tomcat|Tomcat 7.x 2.Enable 3.Browse:D:\Tomcat 7.0 4.JDK:下拉选择JDK7.0,注意:千万不能在此处右键A ...
- 417. Pacific Atlantic Water Flow
正常做的,用了645MS..感觉DFS的时候剪枝有问题.. 为了剪枝可能需要标记一个点的4种情况: 1:滨临大西洋,所有太平洋来的点可以通过: 2:濒临太平洋,所有大西洋来的点可以通过: 3:都不濒临 ...
- WCF服务发布到IIS时候,只能根据hostname访问,不能根据IP地址访问的解决办法
本文转载:http://www.cnblogs.com/deerbox/archive/2013/05/13/3076248.html 环境: VS2010 sp1,.net framework 4. ...
- 摄像头参数查看与调节 分类: C/C++ OpenCV 2014-11-08 18:13 138人阅读 评论(0) 收藏
cvGetCaptureProperty 获得视频获取结构的属性 double cvGetCaptureProperty( CvCapture* capture, int property_id ); ...