在介绍\(Polya\) 定理前,先来介绍一下群论(大概了解一下就好):

群是满足下列要求的集合:

  1. 封闭性:即有一个操作使对于这个集合中每个元素操作完都使这个集合中的元素
  2. 结合律:即对于上面那个操作有结合律
  3. 单位元:对于\(a * e = a\)则称\(e\)是集合\(A\)对于操作\(*\)(并不一定是相乘)的逆元
  4. 逆元:即有\(a * b = b * a = e\)对于元素\(a\)有逆元

    置换群:

    考虑这样的一个全置换集合,可以验证该集合为群。(置换不懂的话建议右转百度,这里不细说)

接下来介绍\(Burnside\)定理

对于一类染色问题,并统计在一些操作下的本质不同方案数有这样一个公式:

我们把所有的操作(类似于顺时针旋转,对称等等)写成一个置换群

则有答案为:

\(ans = \frac{1}{cnt}\sum_{f \in G}p(f)\)

其中\(p(f)\)指的是在该置换下不变的染色方案数。

举例有:

一个大小\(5\)的环,顺时针旋转了\(144\)度的置换为:

\(
\begin{pmatrix}
1&2&3&4&5\\
4&5&1&2&3
\end{pmatrix}
\)

以两种颜色染色则有:

\(
\begin{pmatrix}
1&1&1&1&1
\end{pmatrix}
\)

\(
\begin{pmatrix}
0&0&0&0&0
\end{pmatrix}
\)

两种方案满足对该置换不动。

接下来介绍\(Polya\)定理

考虑把置换写成循环的形式

\(
\begin{pmatrix}
1&2&3&4\\
1&2&3&4
\end{pmatrix}
\)

写作:\((1)(2)(3)(4)\)

\(
\begin{pmatrix}
1&2&3&4\\
3&4&1&2
\end{pmatrix}
\)

写作:\((1\ 3)(2\ 4)\)

则有\(Polya\)定理\(ans = \frac{1}{cnt}\sum_{f \in G}k^{m(f)}\)

\(k\)为染色数,\(m(f)\)为该置换拆解成的循环数。

【模板】Pólya 定理

考虑写出置换后,易证得顺时针旋转\(k\)次的置换的循环为\(gcd(n,k)\)

则有\(ans = \frac{1}{n}\sum_i^n n^{gcd(n,i)}\)

这样复杂度不在承受范围内,考虑枚举\(gcd(n,i)\)

\(ans = \frac{1}{n}\sum_{L|n} n^{L} * \varphi(\frac{n}{L})\)

这样就能在根号里做出答案了。

【模板】Pólya 定理
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
#define mod 1000000007 ll T,n; inline ll pow(ll a,ll b){
ll ans = 1;
while(b){
if(b & 1) ans = 1ll * ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans % mod;
} inline ll phi(int now){
int ans = now;
for(int i = 2;i * i <= now;++i){
if(now % i)continue;
ans = ans - ans / i;
while(now % i == 0)
now /= i;
}
if(now != 1)
ans = ans - ans / now;
return ans % mod;
} inline ll get(int now){ll ans = phi(n / now) * pow(n,now) % mod;} int main(){
scanf("%lld",&T);
while(T -- ){
scanf("%lld",&n);
ll ans = 0;
for(int i = 1;i * i <= n;++i){
if(n % i == 0){
ans = (ans + get(i)) % mod;
if(n / i != i)
ans = (ans + get(n / i)) % mod;
}
}
std::cout<<ans * pow(n,mod - 2) % mod<<std::endl;
}
}

最新文章

  1. 使用canal分析binlog(二) canal源码分析
  2. Swift 2.x -&gt; Swift 3.0
  3. 妈妈再也不担心我的编码问题了。中文编码融汇贯通,windows,django,python,java,html 【转】
  4. 我的ORM之四--删除
  5. C#邮件发送问题(二)
  6. C# for循环及循环嵌套
  7. Mysql数据库备份和按条件导出表数据
  8. margin-top失效及解决办法
  9. 错误21002:[SQL-DMO]用户&quot;xxx&quot;已经存在
  10. 高性能 TCP &amp;amp; UDP 通信框架 HP-Socket v3.2.3 正式公布
  11. R - 变化plot字形,嵌入字体以pdf
  12. WinForm程序的发布
  13. shell编程/字库裁剪(2)——编程过程
  14. UML开发工具Rose ralation的破解安装,
  15. [ZooKeeper] 2 环境搭建
  16. Odoo Linux服务器一键安装脚本使用指南
  17. ASP.NET: Cookie会话丢失,Session超时配置
  18. windows下通过压缩包安装MySQL
  19. MySQL - COUNT关键字
  20. hive建表报错:Specified key was too long; max key length is 767 bytes,hadoophive

热门文章

  1. 你对微信小程序的理解?优缺点?
  2. jsonp和cors解决跨域
  3. 远程设备管理opendx平台搭建-appium和adb的安装
  4. 【UE4 C++】 解析与构建 Json 数据
  5. TypeError: 'encoding' is an invalid keyword argument for this function 解决Python 2.7
  6. Luogu P2149 [SDOI2009]Elaxia的路线 | 图论
  7. 第01课 OpenGL窗口(3)
  8. iscsi基本命令
  9. ELK集群之filebeat(6)
  10. 『学了就忘』Linux基础命令 — 31、grep命令和通配符