传送门

题意:$m$种颜色$n$颗珠子,定义旋转和翻转两种置换,求不等价着色数


暴力求每个置换的循环节也许会$T?$

我们可以发现一些规律:

翻转:

$n$为奇数时每个置换有$1+\frac{n-1}{2}$个循环

$n$为偶数时穿过边的对称有$\frac{n}{2}$个循环,穿过点的有$\frac{n}{2}+1$个循环

旋转:

旋转$i$次的置换的循环个数为$gcd(n,i)$

可以这样想,从一个点开始每次走$i$步最后走到原位的最少步数$a$就是一个循环的长度

$ ai \equiv \pmod n$

$ i \mid ai,n \mid ai \rightarrow a=\frac{lcm(i,n)}{i}$

辣么$\frac{n}{a}=gcd(n,i)$就是循环个数啦

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-; c=getchar();}
while(c>=''&&c<=''){x=x*+c-''; c=getchar();}
return x*f;
}
int m,n;
inline int Pow(int a,int b){
int re=;
for(;b;b>>=,a*=a)
if(b&) re*=a;
return re;
}
inline int gcd(int a,int b){return b==?a:gcd(b,a%b);}
int main(){
freopen("in","r",stdin);
while(true){
m=read();n=read();
if(m==&&n==) break;
int ans=;
for(int i=;i<n;i++) ans+=Pow(m,gcd(n,i));
if(n&) ans+=n*Pow(m,(n+)>>);
else ans+=(n>>)*Pow(m,n>>)+(n>>)*Pow(m,(n>>)+);
ans/=n<<;
printf("%d\n",ans);
}
}

POJ 2409 Let it Bead [置换群 Polya]的更多相关文章

  1. poj 1286 Necklace of Beads &amp; poj 2409 Let it Bead(初涉polya定理)

    http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...

  2. 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:/ ...

  3. POJ 2409 Let it Bead(polya裸题)

    题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...

  4. bzoj 1004 Cards & poj 2409 Let it Bead —— 置换群

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1004 关于置换群:https://www.cnblogs.com/nietzsche-oie ...

  5. POJ 2409 Let it Bead(Polya定理)

    点我看题目 题意 :给你c种颜色的n个珠子,问你可以组成多少种形式. 思路 :polya定理的应用,与1286差不多一样,代码一改就可以交....POJ 1286题解 #include <std ...

  6. POJ 2409 Let it Bead(Polya简单应用)

    Let it Bead 大意:给你m种颜色,n个珠子串起来.旋转跟反转同样算同样,问有多少种不同的涂色组合方式. 思路:Polya的简单应用. /*************************** ...

  7. poj 2409 Let it Bead【polya定理+burnside引理】

    两种置换 旋转:有n种,分别是旋转1个2个--n个,旋转i的循环节数位gcd(i,n) 翻转:分奇偶,对于奇数个,只有一个珠子对一条边的中点,循环节数为n/2+1:对于偶数个,有珠子对珠子和边对边,循 ...

  8. POJ 2409 Let it Bead【Polya定理】(模板题)

    <题目链接> 题目大意:用k种颜色对n个珠子构成的环上色,旋转.翻转后相同的只算一种,求不等价的着色方案数. 解题分析: 对于这种等价计数问题,可以用polay定理来解决,本题是一道pol ...

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

随机推荐

  1. linux系统下,警告:warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration] 和 warning: the `gets' function is dangerous and should not be used. 的由来和解决方法。

    字符数组 的英文名字是 char [] gets()函数的基本用法为:char *gets(char *s); 该函数的参数是一个字符数组,该函数的返回值也是一个字符数组. linux下的代码如下: ...

  2. 去除FineReport报表点击单元格时出现的黑框

    选择模版->模版web属性 添加加载结束事件,具体代码如下 $("td").bind("click",function(){return false;}) ...

  3. python基础1 day2

    一.上节课回顾1. 编译型: 将源码一次性全部编译成二进制. C 优点:执行效率高. 缺点:开发效率慢,不可跨平台使用. 解释型: 当程序执行时,代码一行一行的去解释成二进制. python 优点:开 ...

  4. Oracle_事务

    Oracle_事务 -事物管理   create table account(        id number,        money number );     --实现转账操作 update ...

  5. iptables命令 高级网络

    http://man.linuxde.net/iptables iptables命令是Linux上常用的防火墙软件,是netfilter项目的一部分.可以直接配置,也可以通过许多前端和图形界面配置. ...

  6. 织梦dedecms如何去除版权中的Power by DedeCms

    很多站长在使用dedecms建站过程中,很多人都会调用到dedecms自带的powerby标签,这样在版权信息中就会多出Power by DedeCms这个连接.今天教大家如何去除. 工具/原料 de ...

  7. OKMX6Q在ltib生成的rootfs基础上制作带QT库的根文件系统

    ltib每次执行后会在其目录下生成rootfs目录,并以其为基础生成rootfs.ext2.gz文件,而litb自带的QT库又太老,所以想到按照飞凌的<OKMX6X-S2-Qt4.8.5移植手册 ...

  8. 【开发技术】storyboard和nib的差别

    在使用Storyboard管理的iOS应用中,它的组成部分为AppDelegate和ViewController这两个类以及MainStoryboard.storyboard文件组成.Storyboa ...

  9. hive下UDF函数的使用

    1.编写函数 [java] view plaincopyprint?package com.example.hive.udf;    import org.apache.hadoop.hive.ql. ...

  10. Hystrix-request cache(请求缓存)

    开启请求缓存 请求缓存在run()和construce()执行之前生效,所以可以有效减少不必要的线程开销.你可以通过实现getCachekey()方法来开启请求缓存. package org.hope ...