题目: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. eclipse adt开发android ndk没有NDK选项问题的解决方案

    原创 2015年01月28日 09:38:40 标签: android ndk / eclipse / adt 15989 今天是2015年1月28号,整理一下昨天使用eclipse adt搭建的an ...

  2. 11-利用session校验图片认证码

    /****************************************************************产生随机验证码的servlet******************** ...

  3. CentOS7时间设置及ntp同步配置(转)

    出处:http://www.centoscn.com/CentOS/config/2015/1105/6385.html http://www.centoscn.com/CentOS/config/2 ...

  4. oracle序列sequence

    序列 定义一个序列,自动产生连续的整数.也称序列生成器(sequence generator)产生序列号.在多用户环境下该序列生成器特别有用,可生成各返回序列号而不需要磁盘I/O或事务封锁.序列号为O ...

  5. WebApi 传参详解(转)

    一.无参数Get请求 一般的get请求我们可以使用jquery提供的$.get() 或者$.ajax({type:"get"}) 来实现: 请求的后台Action方法仍为上篇文章中 ...

  6. Html控件和Web控件(转)

    作为一名ASP.NET的初学者,了解并且区别一些混淆概念是很必须的,今天这篇博文 就是主要向大家介绍一下Html控件和Web控件.在ASP.net中,用户界面控件主要就是 Html控件和Web控件,在 ...

  7. 【题解】 P5021赛道修建

    [题解]P5021 赛道修建 二分加贪心,轻松拿省一(我没有QAQ) 题干有提示: 输出格式: 输出共一行,包含一个整数,表示长度最小的赛道长度的最大值. 注意到没,最小的最大值,还要多明显? 那么我 ...

  8. ubuntun下安装sublime text

    Sublime Text 3 是一款轻量级.跨平台的文本编辑器.可安装在ubuntu,Windows和MAC OS X上高级文本编辑软件,有一个专有的许可证,但该程序也可以免费使用,无需做逆向工程.如 ...

  9. shell执行lua脚本传参数

    #lua test.lua 2 5arg[0]= test.lua arg[1]= 2arg[2]= 5 if arg[1] and arg[1] == "2" then prin ...

  10. Django--组件-用户认证Auth(auth_user增加字段)

    引入 :  from django.db import models from django.contrib.auth.models import AbstractBaseUser 源码 :  fro ...