polya定理,环形涂色
环形涂色裸题
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
#define A first
#define B second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define eps 1e-9
#define PIE acos(-1)
#define cl(a,b) memset(a,b,sizeof(a))
#define fastio ios::sync_with_stdio(false);cin.tie(0);
#define lson l , mid , ls
#define rson mid + 1 , r , rs
#define ls (rt<<1)
#define rs (ls|1)
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define sqr(a) a*a
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int, int>
#define dd(x) cout << #x << " = " << (x) << ", "
#define de(x) cout << #x << " = " << (x) << "\n"
#define endl "\n"
using namespace std;
const int mod=1e9+;
int n,m,k,c;
const int maxn=+;
int vis[maxn],lab[maxn];
//**********************************
ll qpow(ll a,ll b)
{
ll ans=;
while(b){
if(b&)ans=ans*a%mod;
a=a*a%mod;
b>>=;
}
return ans;
}
ll getloop()
{
cl(vis,);
int cnt=;
FOR(i,,n){
if(vis[i])continue;
cnt++;
int j=i;
do{
vis[j]=;
j=lab[j];
}while(!vis[j]);
}
return cnt;
}
void work()
{
if(!n){
puts("0\n");return ;
}
ll ans=;
rep(i,,n){
FOR(j,,n)lab[j]=(j+i)%n+;
ans+=qpow(k,getloop());
// FOR(j,1,n/2)swap(lab[j],lab[n+1-j]);ans+=qpow(k,getloop());
ans%=mod;
// de(ans);
}
ans=ans*qpow(n,mod-)%mod;
// ans/=n;
// ans=ans*c%mod;
cout<<ans<<endl;
}
//********************************** //**********************************
int main()
{
// while(~scanf("%d",&n))work();
cin>>m>>n>>c;
k=qpow(c,m*m);
// de(k);
work();
return ;
}
polya定理,环形涂色的更多相关文章
- Polya定理
http://www.cnblogs.com/wenruo/p/5304698.html 先看 Polya定理,Burnside引理回忆一下基础知识.总结的很棒. 一个置换就是集合到自身的一个双射,置 ...
- Burnside引理和Polya定理之间的联系
最近,研究了两天的Burnside引理和Polya定理之间的联系,百思不得其解,然后直到遇到下面的问题: 对颜色限制的染色 例:对正五边形的三个顶点着红色,对其余的两个顶点着蓝色,问有多少种非等价的着 ...
- [洛谷P4980]【模板】Polya定理
题目大意:给一个$n$个点的环染色,有$n$中颜色,问有多少种涂色方案是的旋转后本质不同 题解:$burnside$引理:$ans=\dfrac1{|G|}\sum\limits_{g\in G}A_ ...
- 【数论】【Polya定理】poj1286 Necklace of Beads
Polya定理:设G={π1,π2,π3........πn}是X={a1,a2,a3.......an}上一个置换群,用m中颜色对X中的元素进行涂色,那么不同的涂色方案数为:1/|G|*(mC(π1 ...
- Necklace of Beads(polya定理)
http://poj.org/problem?id=1286 题意:求用3种颜色给n个珠子涂色的方案数.polya定理模板题. #include <stdio.h> #include &l ...
- 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. ...
- Burnside引理与Polya定理
感觉这两个东西好鬼畜= = ,考场上出了肯定不会qwq.不过还是学一下吧用来装逼也是极好的 群的定义 与下文知识无关.. 给出一个集合$G = \{a, b, c, \dots \}$和集合上的二元运 ...
- POJ2154 Color(Polya定理)
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11654 Accepted: 3756 Description Bead ...
- POJ 2409 Let it Bead:置换群 Polya定理
题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...
随机推荐
- python读取ubuntu系统磁盘挂载情况
磁盘挂载 利用df -h 的命令 此功能主要实现了python 命令行执行函数进行解析df 返回的数据 代码如下 : # liunx 系统获取 磁盘挂载的情况 代码 #!/usr/bin/pyt ...
- Marketing Cloud demo环境和API使用方法说明
version 1.0 作者:Wang Jerry 更多问题请联系我 demo 系统url:https:/jerry.hybris.com/sap/bc/ui5_ui5/ui2/ushell/shel ...
- 十:Razor语法
1.Razor简介 不是一种代码语言,而是视图中使用的代码引擎. 它以简洁的类似客户端的语法结构,呈现网页服务端代码功能 它替代了ASPX页面的“<%...%>”代码块语法. 在编写时使用 ...
- Girls Like You--Maroon 5
Girls Like You Spent 24 hours, I need more hours with you (24小时过去 还想和你 相处更久) You spent the weekend g ...
- 一图一知-TS的基本数据类型
- Vasya and Beautiful Arrays CodeForces - 354C (数论,枚举)
Vasya and Beautiful Arrays CodeForces - 354C Vasya's got a birthday coming up and his mom decided to ...
- P1912 [NOI2009]诗人小G
P1912 [NOI2009]诗人小G 思路: 平行四边形不等式优化dp 因为f(j, i) = abs(sum[i]-sum[j]+i-j-1-l)^p 满足平行四边形不等式 j < i f( ...
- Zabbix Web 中文字体显示问题
- Linux命令之tree(目录树结构)
tree命令 官方下载地址:http://mama.indstate.edu/users/ice/tree/,右键复制如下图地址: 下载: 执行wget http://mama.indstate.e ...
- IDEA 2019.1版本 永久激活(假装是永久激活,其实还是有时间的,不过这个时间比较长)
先下载 一个 jar 包 链接: https://pan.baidu.com/s/12eC8OZzMrUve2xC7aRUKLQ 提取码: bavi 将下载下来的jar包,放置你安装idea的目录的b ...