【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][ ...
随机推荐
- [Unity]用PropertyDrawer自定义struct/class的外观
一般来说,当我们要扩展编辑器时,我们会从Editor类继承,为自己的MonoBehaviour实现不同的外观. 但是如果有一个struct/class,在许多地方被使用,Unity默认的外观又不够好看 ...
- POJ 1064 Cable master (二分查找)
题目链接 Description Inhabitants of the Wonderland have decided to hold a regional programming contest. ...
- Spring 路由地址的基本使用
1.下面是spring的使用基本框架连接 https://www.cnblogs.com/HD/p/4103239.html
- CSS哪些样式属性可以继承
不可继承的:display.margin.border.padding.background.height.min-height.max- height.width.min-width.max-wid ...
- 移动端页面使用rem布局
阿里团队的高清布局方案代码 所谓高清方案就是根据设备屏幕的DPR(设备像素比,又称DPPX,比如dpr=2时,表示1个CSS像素由4个物理像素点组成) 动态设置 html 的font-size, 同时 ...
- 4.0docker部署
设置容器的端口映射 -P :容器暴露的所有端口映射 -p :指定映射容器暴露的端口 Nginx部暑流程 docker run -p 80 --name web -t -i ubuntu /bin/b ...
- select下拉箭头改变,兼容ie8/9
各个浏览器下select默认的下拉箭头差别较大,通常会清除默认样式,重新设计 <html> <head> <meta charset="utf-8"& ...
- 比 file_get_contents() 更优的 cURL 详解(附实例)
PHP 可以使用 file_get_content() 函数抓取网页内容,但却无法进行更复杂的处理,譬如文件的上传或下载. Cookie 操作等等.而 cURL 提供了这些功能. 一.cURL简介 在 ...
- make command explaination 編譯命令解釋
Creating .config file make ARCH=arm CROSS_COMPILE=arm-none-eabi- stm32_defconfig 以上命令是 將變數 ARCH=arm, ...
- java===java基础学习(7)---用户自定义类
package testbotoo; import java.util.*; public class EmployeeTest { public static void main(String[] ...