【题目分析】

裸题直接做。

一个长度为n,颜色为m的环,本质不同的染色方案是多少。

数据范围比较小,直接做就好了。

【代码】

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define F(i,j,k) for (int i=j;i<=k;++i)
int gcd(int a,int b)
{return b==0?a:gcd(b,a%b);}
int n,c;
ll pow[50],ans;
int main()
{
while (scanf("%d%d",&c,&n)&&c&&n)
{
ans=0;
pow[0]=1;
F(i,1,n) pow[i]=pow[i-1]*c;
F(i,0,n-1) ans+=pow[gcd(i,n)];
if (n&1) ans+=n*pow[n/2+1];
else
{
ans+=n/2*pow[n/2];
ans+=n/2*pow[n/2+1];
}
ans/=2*n;
printf("%lld\n",ans);
}
}

  

POJ 2409 Let it Bead ——Burnside引理的更多相关文章

  1. POJ 2409 Let it Bead(polay计数)

    题目链接:http://poj.org/problem?id=2409 题意:给出一个长度为m的项链,每个珠子可以用n种颜色涂色.翻转和旋转后相同的算作一种.有多少种不同的项链? 思路: (1) 对于 ...

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

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

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

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

  4. POJ 2888 Magic Bracelet(Burnside引理,矩阵优化)

    Magic Bracelet Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 3731   Accepted: 1227 D ...

  5. poj 2409+2154+2888(Burnside定理)

    三道burnside入门题: Burnside定理主要理解置换群置换后每种不动点的个数,然后n种不动点的染色数总和/n为answer. 对于旋转,旋转i个时不动点为gcd(n,i). 传送门:poj ...

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

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

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

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

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

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

随机推荐

  1. LINUX提高openfire并发数(网上收集)

    谷歌博客地址:http://tsaiquinn.blogspot.com/2014/10/linuxopenfire.html 影响连接数的元素包含三种:1)Linux的系统参数2)进程自身可以创建的 ...

  2. 洛谷 P2617 Dynamic Ranking

    题目描述 给定一个含有n个数的序列a[1],a[2],a[3]……a[n],程序必须回答这样的询问:对于给定的i,j,k,在a[i],a[i+1],a[i+2]……a[j]中第k小的数是多少(1≤k≤ ...

  3. bunzip2命令

    bunzip2——解压缩.bz2格式文件 命令所在路径:/usr/bin/bunzip2 示例1: # bunzip2 yum.log.bz2 解压当前目录下的yum.log.bz2为yum.log, ...

  4. 根据HTML语义化编码

    语义化标签——http://www.html5jscss.com/html5-semantics-section.html 写HTML代码时应注意什么? 尽可能少的使用无语义的标签div和span: ...

  5. 爬虫_python3_urllib

    urlib库为python3的HTTP内置请求库 urilib的四个模块: urllib.request:用于获取网页的响应内容 urllib.error:异常处理模块,用于处理异常的模块 urlli ...

  6. OpenCV2:介绍

    一.OpenCV简介 OpenCV所有的类和函数都在cv命名空间里面,可以用 using namespace cv; #include "opencv2/opencv.hpp" 1 ...

  7. snprintf()返回值的陷阱

    int snprintf(char *restrict buf, size_t n, const char * restrict  format, ...); 函数说明:最多从源串中拷贝n-1个字符到 ...

  8. Oracle 回顾

    Oracle 函数 日期函数: 1.sysdate--查询当前日期 select sysdate from dual;  --查询当前日期 2.months_between--返回两个日期之间的月份差 ...

  9. odoo10 fields.Selection 根据权限显示不同的selection内容

    摘要:一般作为下拉选项,selection的选项内容是固定,针对一些特殊要求,根据权限组显示不同的selection内容的,可以参考odoo源码的. 前提:基于 odoo10.0 的源码 参考源码1: ...

  10. 摘抄 Promise原理

    1.简单的promise: //极简promise雏形 function Promise(fn){ var value = null; callbacks = [];//callback为数组,因为可 ...