传送门

题意:$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. ionic2 安装与cordova打包

    1.安装: cnpm install -g cordova ionic ionic start name cd name cnpm install   2.环境配置: http://www.cnblo ...

  2. js根据出生年月日换算年龄

    function age_Conversion(date) { debugger var age = ''; var str = date.replace(/年|月/g, "-") ...

  3. PHPStorm+PHPStudy新建第一个PHP项目

    img { max-width: 100% } 熟悉了.net的编程,偶尔也来客串一下PHP.前几天闲来无事随便加了一个PHP的开发群,入群之后傻眼了,群里有大小各位程工1600多人,所以决定学习一下 ...

  4. git常用命令--转载

    http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html

  5. vue-cli的webpack模版项目配置解析-build/dev-server.js

    我们在使用vue-cli搭建vuejs项目(Vuejs实例-01使用vue-cli脚手架搭建Vue.js项目)的时候,会自动生成一系列文件,其中就包含webpack配置文件.我们现在来看下,这些配置到 ...

  6. css cursor属性-显示的光标的类型(形状)的用法和定义

    在网页布局的时候,在特定的地方,光标形状各有区别.这个时候,就需要用到css的cursor属性.根据自身需要选择设置鼠标指针样式. 定义和用法 cursor 属性规定要显示的光标的类型(形状). 该属 ...

  7. 【编程技巧】ExtJs 设置GridPanel表格文本垂直居中

    详细讲解见 http://blog.csdn.net/li396864285/article/details/9310983 以下是我改修的代码: {         width:90,        ...

  8. 【开发技术】json

    json(JavaScript Object Notation) JavaScript对象符号是一种结构化轻量级的数据传输格式,很多场合替代XML文件格式 JSON格式化校验:http://www.b ...

  9. C# 将Access中时间段条件查询的数据添加到ListView中

    C# 将Access中时间段条件查询的数据添加到ListView中 一.让ListView控件显示表头的方法 在窗体中添加ListView 空间,其属性中设置:View属性设置为:Detail,Col ...

  10. 2018/1/27 每日一学 最长不降序子序列的O(n*logn)算法

    手动维护一个数组模拟即可,233-- 可以使用algorithm中的lower_bound(相当于二分) 代码如下: #include<cstdio> #include<algori ...