环形涂色裸题

 #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定理,环形涂色的更多相关文章

  1. Polya定理

    http://www.cnblogs.com/wenruo/p/5304698.html 先看 Polya定理,Burnside引理回忆一下基础知识.总结的很棒. 一个置换就是集合到自身的一个双射,置 ...

  2. Burnside引理和Polya定理之间的联系

    最近,研究了两天的Burnside引理和Polya定理之间的联系,百思不得其解,然后直到遇到下面的问题: 对颜色限制的染色 例:对正五边形的三个顶点着红色,对其余的两个顶点着蓝色,问有多少种非等价的着 ...

  3. [洛谷P4980]【模板】Polya定理

    题目大意:给一个$n$个点的环染色,有$n$中颜色,问有多少种涂色方案是的旋转后本质不同 题解:$burnside$引理:$ans=\dfrac1{|G|}\sum\limits_{g\in G}A_ ...

  4. 【数论】【Polya定理】poj1286 Necklace of Beads

    Polya定理:设G={π1,π2,π3........πn}是X={a1,a2,a3.......an}上一个置换群,用m中颜色对X中的元素进行涂色,那么不同的涂色方案数为:1/|G|*(mC(π1 ...

  5. Necklace of Beads(polya定理)

    http://poj.org/problem?id=1286 题意:求用3种颜色给n个珠子涂色的方案数.polya定理模板题. #include <stdio.h> #include &l ...

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

  7. Burnside引理与Polya定理

    感觉这两个东西好鬼畜= = ,考场上出了肯定不会qwq.不过还是学一下吧用来装逼也是极好的 群的定义 与下文知识无关.. 给出一个集合$G = \{a, b, c, \dots \}$和集合上的二元运 ...

  8. POJ2154 Color(Polya定理)

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11654   Accepted: 3756 Description Bead ...

  9. POJ 2409 Let it Bead:置换群 Polya定理

    题目链接:http://poj.org/problem?id=2409 题意: 有一串n个珠子穿起来的项链,你有k种颜色来给每一个珠子染色. 问你染色后有多少种不同的项链. 注:“不同”的概念是指无论 ...

随机推荐

  1. select input 等控件进行清空操作

    <html> <head> <meta charset="utf-8" /> <title></title> <s ...

  2. JDBC 插入时间字段的值

    ps.setTimestamp(6, new Timestamp(System.currentTimeMillis()));

  3. Mac下安装Redis及Redis Desktop Manager

    1.简介 Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库.缓存和消息中间件. 它支持多种类型的数据结构,如 字符串(strings), 散列(hashes), 列表 ...

  4. python3 中的cls和self的区别 静态方法和类方法的区别

      一般来说,要使用某个类的方法,需要先实例化一个对象再调用方法. 而使用@staticmethod或@classmethod,就可以不需要实例化,直接类名.方法名()来调用. 这有利于组织代码,把某 ...

  5. Android Stdio部分配置

    一.Error:Cause: unable to find valid certification path to requested target主要是在根目录的build.gradle下配置的jc ...

  6. java 日期。时间

    友情链接: https://www.cnblogs.com/wanson/articles/10818955.html

  7. 【uoj#46】 [清华集训2014] 玄学

      题目传送门:uoj46   题意简述:要求在序列上维护一个操作间支持结合律的区间操作,查询连续一段时间内的操作对单点的作用效果,\(n \leq 10^5,m \leq 6 \times 10^5 ...

  8. Java 读取 .properties 文件的几种方式

    Java 读取 .properties 配置文件的几种方式   Java 开发中,需要将一些易变的配置参数放置再 XML 配置文件或者 properties 配置文件中.然而 XML 配置文件需要通过 ...

  9. django的几种缓存配置

    前言 首先说,为什么要用缓存的,由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存 ...

  10. windows配置mysql权限

    想要把csv里面的数据导入mysql,报错.用命令      show variables like '%secure%';   : [2019-04-08 17:04:36] [HY000][129 ...