题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004

关于置换群:https://www.cnblogs.com/nietzsche-oier/p/6883880.html

https://files-cdn.cnblogs.com/files/HocRiser/Burnside.pdf

原来 burnside 引理中的“不动点”是指一种不变化的方案啊;

这道题就用 burnside 引理,但给出的 m 个置换还不是置换群,需要再加一个单位元,即 \( a[i] = i \) 的置换;

用三维DP求出每种置换的“不动点”个数,枚举可以通过记录总数而减少一维。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int const xn=,xm=;
int n,m,sr,sb,sg,a[xn],f[xm][xm][xm],mod,tot;
bool vis[xn];
int rd()
{
int ret=,f=; char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=; ch=getchar();}
while(ch>=''&&ch<='')ret=ret*+ch-'',ch=getchar();
return f?ret:-ret;
}
ll pw(ll a,int b)
{
ll ret=;
for(;b;b>>=,a=(a*a)%mod)if(b&)ret=(ret*a)%mod;
return ret;
}
int upt(int x){while(x>=mod)x-=mod; while(x<)x+=mod; return x;}
void dfs(int x)
{
tot++; vis[x]=;
if(!vis[a[x]])dfs(a[x]);
}
int main()
{
sr=rd(); sb=rd(); sg=rd(); m=rd(); mod=rd();
n=sr+sb+sg; m++;
for(int i=;i<=m;i++)
{
memset(vis,,sizeof vis);
memset(f,,sizeof f); f[][][]=;//
if(i==m)for(int j=;j<=n;j++)a[j]=j;
else for(int j=;j<=n;j++)a[j]=rd(),vis[j]=;
tot=; int res=;
for(int j=;j<=n;j++)
{
if(vis[j])continue;
tot=; dfs(j); res+=tot;
for(int j=sr;j>=;j--)
for(int k=sb;k>=;k--)
//for(int l=sg;l>=0;l--)
{
int l=res-j-k; if(l<)continue;
if(j>=tot)f[j][k][l]=upt(f[j][k][l]+f[j-tot][k][l]);
if(k>=tot)f[j][k][l]=upt(f[j][k][l]+f[j][k-tot][l]);
if(l>=tot)f[j][k][l]=upt(f[j][k][l]+f[j][k][l-tot]);
}
}
}
printf("%lld\n",(ll)f[sr][sb][sg]*pw(m,mod-)%mod);
return ;
}

题目:http://poj.org/problem?id=2409

Polya 定理裸题;

gcd 可以从模的剩余系的角度来看;

注意加上翻转后有 2n 个置换。

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int const xn=;
int n,m;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int pw(int a,int b)
{
int ret=;
for(;b;b>>=,a=a*a)if(b&)ret=ret*a;
return ret;
}
int main()
{
while()
{
scanf("%d%d",&m,&n);
if(!m&&!n)return ;
int ans=;
for(int i=;i<=n;i++)ans+=pw(m,gcd(n,i));
if(n%)ans+=n*pw(m,n/+);
else ans+=n/*pw(m,n/)+n/*pw(m,n/+);
printf("%d\n",ans//n);//2n
}
return ;
}

bzoj 1004 Cards & poj 2409 Let it Bead —— 置换群的更多相关文章

  1. 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:/ ...

  2. POJ 2409 Let it Bead [置换群 Polya]

    传送门 题意:$m$种颜色$n$颗珠子,定义旋转和翻转两种置换,求不等价着色数 暴力求每个置换的循环节也许会$T?$ 我们可以发现一些规律: 翻转: $n$为奇数时每个置换有$1+\frac{n-1} ...

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

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

  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 2409 Let it Bead(polya裸题)

    题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...

  6. bzoj 1004 Cards

    1004: [HNOI2008]Cards Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有 多少种染色方案,Sun ...

  7. POJ 2409 Let it Bead(polay计数)

    题目链接:http://poj.org/problem?id=2409 题意:给出一个长度为m的项链,每个珠子可以用n种颜色涂色.翻转和旋转后相同的算作一种.有多少种不同的项链? 思路: (1) 对于 ...

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

  9. POJ 2409 Let it Bead 组合数学

    题目地址: http://poj.org/problem?id=2409 给你一串珠子有m个,用n种不同的颜色涂色,问有多少种分法. 用polay定理求解,对于排成一排的带编号的小球,按照某一种方案改 ...

随机推荐

  1. Spring Resource框架体系介绍

    Resource介绍 在使用spring作为容器进行项目开发中会有很多的配置文件,这些配置文件都是通过Spring的Resource接口来实现加载,但是,Resource对于所有低级资源的访问都不够充 ...

  2. (webstorm的CSS插件)前端开发必备!Emmet使用手册

    介绍 Emmet (前身为 Zen Coding) 是一个能大幅度提高前端开发效率的一个工具: 基本上,大多数的文本编辑器都会允许你存储和重用一些代码块,我们称之为“片段”.虽然片段能很好地推动你得生 ...

  3. java从apk文件获取包名、版本号、icon

    依赖:仅依赖aapt.exe 支持:仅限windows 功能:用纯java获取apk文集里的包名,版本号,图标文件[可获取到流直接保存到文件系统] 原理:比较上一篇文章里通过反编译然后解析Androi ...

  4. JavaWeb、J2-SE开发框架——Spring

    相关博客:   2.spring官网 1.使用Spring的jdbcTemplate进一步简化JDBC操作

  5. java jdbc oracle ORA-01795: 列表中的最大表达式数为 1000

    在操作SQL中存在In的数量如果超过1000条会提示   ORA-01795: 列表中的最大表达式数为 1000 归纳有几种方式出现的: 第一种是:我在上一个 [jdbc 同时执行 查询和删除操]作中 ...

  6. python 基础 6.0 异常的常用形式

    一. 异常   异常既是一个时间,该事件会在程序执行过程中发生,影响了程序的正常执行.一般情况下,在python无法正常处理程序时就会发生一个异常.异常是python对象,表示一个错误.当python ...

  7. EasyPlayerPro Windows播放器进行本地对讲喊话音频采集功能实现

    需求 在安防行业应用中,除了在本地看到摄像机的视频和进行音频监听外,还有一个重要的功能,那就是对讲. EasyPlayerPro-win为了减轻二次开发者的工作量,将本地音频采集也进行了集成: 功能特 ...

  8. Socket的错误码和描述

    //下面是Socket Error的错误码和描述: Socket error 0 - Directly send error  Socket error 10004 - Interrupted fun ...

  9. 怎么使用Aspose.Cells读取excel 转化为Datatable

    说明:vs2012 asp.net mvc4 c# 使用Aspose.Cells 读取Excel 转化为Datatable 1.HTML前端代码 <%@ Page Language=" ...

  10. pycharm注册码地址

    (1)地址:http://idea.lanyus.com/ (2)注意,在破解的时候,是先修改hosts文件所在路径:“C:\Windows\System32\drivers\etc\hosts”,修 ...