题目: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. Java 8 Collectors to Map

    1. 介绍 在本教程中,我们将讨论Collectors类的toMap()方法.我们使用它将流收集到一个Map实例中. 对于本教程中涉及的所有示例,我们将使用图书列表作为数据源,并将其转换为不同的Map ...

  2. The Google File System论文拜读

    The Google File System Sanjay Ghemawat, Howard Gobioff, and Shun-Tak Leung Google∗ 摘要 我们设计并实现了谷歌文件系统 ...

  3. C#的类型列表

    以下是 C# 内建类型的列表: 类型 字节 描述 unsigned byte signed byte signed short unsigned short signed integer unsign ...

  4. 多媒体开之之rtp 时间戳和负载类型介绍

    (1)时间戳 (2)负载类型 (3)rtp 包头 (1)时间戳 有三个 一个实时间单位 timestamp_increse=(unsigned int)(90000.0 / framerate); / ...

  5. Windows系统下正确安装MongoDB

    1.下载.安装 官网下载: http://www.mongodb.org/downloads 下载好之后,接下来进行安装了: 2.创建数据文件夹 MongoDB将数据文件夹存储在 db 文件夹下. 可 ...

  6. spring AOP(切面) 表达式介绍

    在 spring AOP(切面) 例子基础上对表达式进行介绍 1.添加接口删除方法 2.接口实现类 UserDaoServer 添加实现接口删除方法 3.测试类调用delUser方法 4. 输出结果截 ...

  7. 再看python多线程------threading模块

    现在把关于多线程的能想到的需要注意的点记录一下: 关于threading模块: 1.关于 传参问题 如果调用的子线程函数需要传参,要在参数后面加一个“,”否则会抛参数异常的错误. 如下: for i ...

  8. 九度OJ 1015:还是A+B (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:6773 解决:4031 题目描述: 读入两个小于10000的正整数A和B,计算A+B.需要注意的是:如果A和B的末尾K(不超过8)位数字相同 ...

  9. 【题解】cycle

    [题解]cycle 题目描述 给定一个无向图,求一个环,使得环内边权\(\div\)环内点数最大. 数据范围 \(n \le 5000\) \(m\le 10000\) \(Solution\) 考虑 ...

  10. 我的Java开发学习之旅------>Java经典排序算法之二分插入排序

    一.折半插入排序(二分插入排序) 将直接插入排序中寻找A[i]的插入位置的方法改为采用折半比较,即可得到折半插入排序算法.在处理A[i]时,A[0]--A[i-1]已经按关键码值排好序.所谓折半比较, ...