POJ 2409 Let it Bead [置换群 Polya]
题意:$m$种颜色$n$颗珠子,定义旋转和翻转两种置换,求不等价着色数
暴力求每个置换的循环节也许会$T?$
我们可以发现一些规律:
翻转:
$n$为奇数时每个置换有$1+\frac{n-1}{2}$个循环
$n$为偶数时穿过边的对称有$\frac{n}{2}$个循环,穿过点的有$\frac{n}{2}+1$个循环
旋转:
旋转$i$次的置换的循环个数为$gcd(n,i)$
可以这样想,从一个点开始每次走$i$步最后走到原位的最少步数$a$就是一个循环的长度
$ ai \equiv \pmod n$
$ i \mid ai,n \mid ai \rightarrow a=\frac{lcm(i,n)}{i}$
辣么$\frac{n}{a}=gcd(n,i)$就是循环个数啦
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-; c=getchar();}
while(c>=''&&c<=''){x=x*+c-''; c=getchar();}
return x*f;
}
int m,n;
inline int Pow(int a,int b){
int re=;
for(;b;b>>=,a*=a)
if(b&) re*=a;
return re;
}
inline int gcd(int a,int b){return b==?a:gcd(b,a%b);}
int main(){
freopen("in","r",stdin);
while(true){
m=read();n=read();
if(m==&&n==) break;
int ans=;
for(int i=;i<n;i++) ans+=Pow(m,gcd(n,i));
if(n&) ans+=n*Pow(m,(n+)>>);
else ans+=(n>>)*Pow(m,n>>)+(n>>)*Pow(m,(n>>)+);
ans/=n<<;
printf("%d\n",ans);
}
}
POJ 2409 Let it Bead [置换群 Polya]的更多相关文章
- 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 2409 Let it Bead(polya裸题)
题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...
- bzoj 1004 Cards & poj 2409 Let it Bead —— 置换群
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004 关于置换群:https://www.cnblogs.com/nietzsche-oie ...
- POJ 2409 Let it Bead(Polya定理)
点我看题目 题意 :给你c种颜色的n个珠子,问你可以组成多少种形式. 思路 :polya定理的应用,与1286差不多一样,代码一改就可以交....POJ 1286题解 #include <std ...
- POJ 2409 Let it Bead(Polya简单应用)
Let it Bead 大意:给你m种颜色,n个珠子串起来.旋转跟反转同样算同样,问有多少种不同的涂色组合方式. 思路:Polya的简单应用. /*************************** ...
- poj 2409 Let it Bead【polya定理+burnside引理】
两种置换 旋转:有n种,分别是旋转1个2个--n个,旋转i的循环节数位gcd(i,n) 翻转:分奇偶,对于奇数个,只有一个珠子对一条边的中点,循环节数为n/2+1:对于偶数个,有珠子对珠子和边对边,循 ...
- POJ 2409 Let it Bead【Polya定理】(模板题)
<题目链接> 题目大意:用k种颜色对n个珠子构成的环上色,旋转.翻转后相同的只算一种,求不等价的着色方案数. 解题分析: 对于这种等价计数问题,可以用polay定理来解决,本题是一道pol ...
- 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 ...
随机推荐
- 整数n的全排列
第一道用搜索码的.得纪念一下 #include <iostream> #include <cstdio> #include <cstring> #include & ...
- Zabbix安装客户端agent(windows和Centos7)
上一篇简单的介绍了怎么搭建Zabbix监控服务端,接下来给大家介绍怎么在windows和Centos7上安装zabbix_agent客户端. Zabbix是一个基于WEB界面的提供分布式系统监视以及网 ...
- Pycharm+django新建Python Web项目
这两天初学Python,首先是学习Python语法有PyCharm就可以运行Console程序了,因为是初学所以,尽量写的比较详细,包括参考的资料地址... 1.下载Python,并安装[本文版本 ...
- 把自己的js模块兼容到AMD CMD CommonJS
为了让同一个模块可以运行在前后端,在写作过程中需要考虑兼容前端也实现了模块规范的环境.为了保持前后端的一致性,类库开发者需要将类库代码包装在一个闭包内.以下代码演示如何将hello()方法定义到不同的 ...
- 数据库01创建表和DML语言
楼主用的数据库时mysql,用的时navacat for mysql. 数据库层面: 1.显示所有数据库 show databases; 2.创建数据库,名字叫lyh,编码为utf-8 create ...
- 虚拟主机导入MySQL出现Unknown character set: ‘utf8mb4’
http://www.lmlblog.com/14.html 前几天进行网站搬家,MySQL导入数据的时候,出现以下错误(没有定义的编码集utf8mb4): SQL 查询: ; MySQL 返回:文档 ...
- 阿里大鱼 阿里云api
阿里短信服务API接入指南及示例 : https://yq.aliyun.com/articles/59928 =========================================== ...
- Ubuntu16.04安装mongodb
Ubuntu16.04安装mongodb copy from: http://blog.csdn.net/zhushh/article/details/52451441 1.导入软件源的公钥 sudo ...
- [转]linux下centos服务器安全设置
引言: 我们必须明白:最小的权限+最少的服务=最大的安全 所以,无论是配置任何服务器,我们都必须把不用的服务关闭.把系统权限设置到最小话,这样才能保证服务器最大的安全.下面是CentOS服务器安全设置 ...
- bootstrap-table 表格加载中....处理
$('#table').bootstrapTable({data:[]}); $('#table').bootstrapTable("showLoading"); ajax数据加载 ...