题目: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. 深入Asyncio(一)入门介绍

    介绍 Asyncio试图解决什么问题? 对于IO负载,有且仅有两个理由使用基于asyncio的并发而不是基于多线程的并发: 1. Asyncio为抢占式多任务(线程)提供了一个更安全的替代方案,避免了 ...

  2. maven新建项目报错

    创建了一个maven项目,报错 Errors occurred during the build. Errors running builder 'Maven Project Builder' on ...

  3. WPF自定义搜索框代码分享

    首先下载搜索图标: 控件中的搜索图标下载地址:http://www.easyicon.net/1183666-Search_icon.html 搜索框设计过程比较简单: 1.先定义一个Rectangl ...

  4. programming review (c++): (3)graph, binary search

    I.graph #include <iostream> #include <vector> using namespace std; vector<vector<, ...

  5. 微信小程序页面之间的跳转

    一.使用标签跳转             index.wxml:             在index.wxml页面添加一个<navigator>元素,在元素里面使用属性url就可以 二. ...

  6. T-SQL简单查询语句(模糊查询)

    T-SQL简单查询语句 简单查询: 1.最简单查询(查所有数据) select * from 表名: 注:* 代表所有列 select * from info 2.查询指定列 select code, ...

  7. restlet验证

    1 restlet有无认证对比 无认证: 客户端发起请求 -----> 服务器路由 -----> 访问服务端资源 有认证: 客户端发起请求 -----> 认证 ----->服务 ...

  8. Jeff Dean 排序时间计算

    Quicksort (sometimes called partition-exchange sort) https://en.m.wikipedia.org/wiki/Quicksort

  9. Hadoop实战-Flume之Sink Failover(十六)

    a1.sources = r1 a1.sinks = k1 k2 a1.channels = c1 # Describe/configure the source a1.sources.r1.type ...

  10. HNOI2017

    本蒟蒻表示终于把$HNOI2017$全AC了... 万岁! 附上各个题的题解: $DAY1$: $T1$: BZOJ4825: [Hnoi2017]单旋 $T2$: BZOJ4826: [Hnoi20 ...