【POJ 2409】Let it Bead
http://poj.org/problem?id=2409
Burnside引理:设\(G\)是\(X\)的置换群,而\(\mathcal{C}\)是\(X\)中一个满足下面条件的着色集合:对于\(G\)中所有的\(f\)和\(\mathcal{C}\)中所有的\(\mathbf{c}\)都有\(f*\mathbf{c}\)仍在\(\mathcal{C}\)中,则\(\mathcal{C}\)中非等价着色数\(N(G,\mathcal{C})\)由下式给出:$$N(G,\mathcal{C})=\frac 1{|G|}\sum_{f\in G}|\mathcal{C}(f)|$$
换言之,\(\mathcal{C}\)中非等价的着色数等于在\(G\)中的置换作用下保持不变的着色的平均数。
直接套用定理就可以了qwq
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int ipow(int a, int b) {
int ret = 1, w = a;
while (b) {
if (b & 1) ret *= w;
w *= w;
b >>= 1;
}
return ret;
}
int c, s, ans, half;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int main() {
while (~scanf("%d%d", &c, &s)) {
if (c == 0 && s == 0) break;
ans = 0;
for (int i = 1; i <= s; ++i)
ans += ipow(c, gcd(i, s));
half = (s + 1) >> 1;
if (s & 1)
ans += s * ipow(c, half);
else
ans += (s >> 1) * (ipow(c, half) + ipow(c, half + 1));
printf("%d\n", ans / (s << 1));
}
return 0;
}
【POJ 2409】Let it Bead的更多相关文章
- 【POJ 2409】 Let it Bead(置换、burnside引理)
Let it Bead "Let it Bead" company is located upstairs at 700 Cannery Row in Monterey, CA. ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- 【链表】BZOJ 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 382 Solved: 111[Submit][S ...
- BZOJ2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 284 Solved: 82[Submit][St ...
- BZOJ2293: 【POJ Challenge】吉他英雄
2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 80 Solved: 59[Submit][Stat ...
- BZOJ2287: 【POJ Challenge】消失之物
2287: [POJ Challenge]消失之物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 254 Solved: 140[Submit][S ...
- BZOJ2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 126 Solved: 90[Submit][Sta ...
- BZOJ2296: 【POJ Challenge】随机种子
2296: [POJ Challenge]随机种子 Time Limit: 1 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 114 Solv ...
- BZOJ2292: 【POJ Challenge 】永远挑战
2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 513 Solved: 201[Submit][ ...
随机推荐
- 【51NOD-0】1106 质数检测
[算法]数学 #include<cstdio> #include<cmath> bool ok(int x) { int m=(int)sqrt(x+0.5); ;i<= ...
- [bzoj1005][HNOI2008]明明的烦恼-Prufer编码+高精度
Brief Description 给出标号为1到N的点,以及某些点最终的度数,允许在 任意两点间连线,可产生多少棵度数满足要求的树? Algorithm Design 结论题. 首先可以参考这篇文章 ...
- Gulp、Grunt构建工具
在Gulp中创建一个库从磁盘gulp.src读取源文件并通过磁盘管道写回内容到gulp.dest,可以理解成只是将文件复制到另一个目录. var gulp = require('gulp'); gul ...
- 关于win7局域网共享的相关设置
模式1> 被访问方相关设置步骤: (1)被共享方的电脑开通来宾用户 (2)被共享方的电脑的本地安全策略需要设置成 "仅来宾" (3)被共享方的电脑高级共享设置中 " ...
- php中类的static变量使用
<?php #访问静态变量 #类外部: 类名::$类变量名 #类内部: 娄名::$类变量名或self::$类变量名 class Char{ public static $number = 0; ...
- python3中处理url异常
import urllib.request import urllib.error url = 'http://c.telunyun.com/Chart/getJsonData?market=1' d ...
- pinctrl框架【转】
转自:http://www.cnblogs.com/kevinhwang/p/5703192.html pinctrl框架是linux系统为统一各SOC厂家pin管理,目的是为了减少SOC厂家系统移植 ...
- USB 3.1 與 USB Type-C 解釋
https://tw.transcend-info.com/Support/FAQ-940 以下的內容皆來自上面這個網址. 什麼是USB 3.1? 什麼是USB 3.1? USB 3.1為USB協會制 ...
- 虚拟机安装苹果系统 VMware 12安装Mac OS X 10.10
工具/原料 VMware Workstation Pro 12 (这个可以自己下载,并激活,你懂得) Unlocker 207 (链接:http://pan.baidu.com/s/1i43obDb ...
- php设计模式六----桥接模式
1.简介 桥接(Bridge)是用于把抽象化与实现化解耦,使得二者可以独立变化.这种类型的设计模式属于结构型模式,它通过提供抽象化和实现化之间的桥接结构,来实现二者的解耦. 这种模式涉及到一个作为桥接 ...