题目链接:http://poj.org/problem?id=2409

题意:给出一个长度为m的项链,每个珠子可以用n种颜色涂色。翻转和旋转后相同的算作一种。有多少种不同的项链?

思路:

(1)

对于Burnside引理,G为所有置换集合,|G|为所有置换个数,gi为第i种置换,D(gi)为在第i种置换下保持不动的元素个数。

对于Polay定理,G为所有置换集合,|G|为所有置换个数,gi为第i种置换,n为颜色的种类,c(gi)为第i种置换的循环节个数。

(2)对于Polay,一般解题步骤:确定循环群;计算每种循环下的循环节个数。

对于本题,旋转可以分为旋转i=0,1,2,……m-1个,循环节个数为Gcd(m,i)。对于翻转,若m为奇数,只有通过一顶点和其对边中点的轴翻转,循环节m/2+1;对于m为偶数,两种翻转的轴,第一是两个顶点的连线,循环节m/2+1,第二是对边中点的连线,循环节m/2。

#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <map>

#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define abs(x) ((x)>=0?(x):-(x))
#define i64 long long
#define u32 unsigned int
#define u64 unsigned long long
#define clr(x,y) memset(x,y,sizeof(x))
#define CLR(x) x.clear()
#define ph(x) push(x)
#define pb(x) push_back(x)
#define Len(x) x.length()
#define SZ(x) x.size()
#define PI acos(-1.0)
#define sqr(x) ((x)*(x))

#define FOR0(i,x) for(i=0;i<x;i++)
#define FOR1(i,x) for(i=1;i<=x;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FORL0(i,a) for(i=a;i>=0;i--)
#define FORL1(i,a) for(i=a;i>=1;i--)
#define FORL(i,a,b)for(i=a;i>=b;i--)

#define rush() int CC;for(scanf("%d",&CC);CC--;)
#define Rush(n)  while(scanf("%d",&n)!=-1)
using namespace std;

void RD(int &x){scanf("%d",&x);}
void RD(i64 &x){scanf("%I64d",&x);}
void RD(u64 &x){scanf("%I64u",&x);}
void RD(u32 &x){scanf("%u",&x);}
void RD(double &x){scanf("%lf",&x);}
void RD(int &x,int &y){scanf("%d%d",&x,&y);}
void RD(i64 &x,i64 &y){scanf("%I64d%I64d",&x,&y);}
void RD(u32 &x,u32 &y){scanf("%u%u",&x,&y);}
void RD(double &x,double &y){scanf("%lf%lf",&x,&y);}
void RD(int &x,int &y,int &z){scanf("%d%d%d",&x,&y,&z);}
void RD(i64 &x,i64 &y,i64 &z){scanf("%I64d%I64d%I64d",&x,&y,&z);}
void RD(u32 &x,u32 &y,u32 &z){scanf("%u%u%u",&x,&y,&z);}
void RD(double &x,double &y,double &z){scanf("%lf%lf%lf",&x,&y,&z);}
void RD(char &x){x=getchar();}
void RD(char *s){scanf("%s",s);}
void RD(string &s){cin>>s;}

void PR(int x) {printf("%d\n",x);}
void PR(int x,int y) {printf("%d %d\n",x,y);}
void PR(i64 x) {printf("%lld\n",x);}
void PR(u32 x) {printf("%u\n",x);}
void PR(u64 x) {printf("%I64u\n",x);}
void PR(double x) {printf("%.10lf\n",x);}
void PR(char x) {printf("%c\n",x);}
void PR(char *x) {printf("%s\n",x);}
void PR(string x) {cout<<x<<endl;}

const i64 inf=((i64)1)<<60;
const int mod=10007;
const double dinf=1e50;
const int INF=1000000000;
const int N=55;

int n,m;

int Gcd(int x,int y)
{
    if(!y) return x;
    return Gcd(y,x%y);
}

int Pow(int x,int y)
{
    int ans=1;
    while(y)
    {
        if(y&1) ans*=x;
        x=x*x;
        y>>=1;
    }
    return ans;
}

int main()
{
    Rush(n)
    {
        RD(m);
        if(!n&&!m) break;
        int ans=0,i;
        FOR0(i,m) ans+=Pow(n,Gcd(m,i));
        if(m&1) ans+=m*Pow(n,m/2+1);
        else ans+=m/2*Pow(n,m/2)+m/2*Pow(n,m/2+1);
        ans/=(2*m);
        PR(ans);
    }
    return 0;
}

POJ 2409 Let it Bead(polay计数)的更多相关文章

  1. [ACM] POJ 2409 Let it Bead (Polya计数)

    参考:https://blog.csdn.net/sr_19930829/article/details/38108871 #include <iostream> #include < ...

  2. poj 2409 Let it Bead Polya计数

    旋转能够分为n种置换,相应的循环个数各自是gcd(n,i),个i=0时不动,有n个 翻转分为奇偶讨论,奇数时有n种置换,每种有n/2+1个 偶数时有n种置换,一半是n/2+1个,一半是n/2个 啃论文 ...

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

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

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

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

  6. POJ 2409 Let it Bead 组合数学

    题目地址: http://poj.org/problem?id=2409 给你一串珠子有m个,用n种不同的颜色涂色,问有多少种分法. 用polay定理求解,对于排成一排的带编号的小球,按照某一种方案改 ...

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

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

  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:置换群 Polya定理

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

随机推荐

  1. ubuntu 下dbus的环境搭建和使用

    从https://launchpad.net/ubuntu/+source/dbus/1.10.6-1ubuntu2下载需要的dbus包,然后解压,./configure make && ...

  2. ios应用启动后的自动版本检测方式

    今天意外的发现了appstore居然还提供通过url获取json格式的客户端信息链接: http://itunes.apple.com/lookup?id=$id 通过此地址可以获取应用的icon.介 ...

  3. 将日志搬家到自己的站点 http://nowhereman.cn/

    个人站点同步地址 : http://nowhereman.cn/

  4. iOS开发网络篇—大文件的多线程断点下载(转)

    http://www.cnblogs.com/wendingding/p/3947550.html   iOS开发网络篇—多线程断点下载 说明:本文介绍多线程断点下载.项目中使用了苹果自带的类,实现了 ...

  5. define的用法

    define的用法小结 define的用法只是一种纯粹的替换功能,宏定义的替换是预处理器处理的替换. 一:简单的宏定义用法 格式:#define 标识符 替换内容 替换的内容可以是数字,字符,字符串, ...

  6. sql2008还原问题

    2003的服务器系统不知是因为对SSD的支持不好还是别的原因,系统使用有很多奇怪的问题,所以就升级一下系统,在备份数据库的时候出现了各种问题 源数据库与现数据库都为sqlserver2008,并都安装 ...

  7. C# Double toString保留小数点方法

    有时候double型数据需要toString(),但又想保留小数,当值为整数,比如3.00时tostring后会变为”3″,具体说明见下: 1 string str0 = i.ToString(&qu ...

  8. BOM-字节序标记

    BOM——Byte Order Mark 字节序标记 首先是什么是字节序? 字节序:与二进制数据在机器存放位置相关的! 可分为两类: 1. 小端字节序: 低地址放低位数据. x86系列的计算机就使用这 ...

  9. 1021 玛丽卡 - Wikioi

    题目描述 Description麦克找了个新女朋友,玛丽卡对他非常恼火并伺机报复. 因为她和他们不住在同一个城市,因此她开始准备她的长途旅行. 在这个国家中每两个城市之间最多只有一条路相通,并且我们知 ...

  10. 【BZOJ】【1391】【CEOI2008】order

    网络流/最小割 暴力建图就好了……S->i 容量为收益,i->j+n 容量为租金,j+n->T容量为购买所花的钱. 如果亏钱的话那么割掉的就是收益,表示不赚钱. 如果租金大于购买所花 ...