【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][ ...
随机推荐
- MyBatis 系列五 之 延迟加载、一级缓存、二级缓存设置
MyBatis的延迟加载.一级缓存.二级缓存设置 首先我们必须分清延迟加载的适用对象 延迟加载 MyBatis中的延迟加载,也称为懒加载,是指在进行关联查询时,按照设置延迟加载规则推迟对关联对象的se ...
- 密码本(无bug版)
main.cpp #include <stdio.h> #include <stdlib.h> #include "data.h" #include &qu ...
- Exponial (欧拉定理+指数循环定理+欧拉函数+快速幂)
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2021 Description Everybody loves big numbers ...
- 阿里云服务器部署笔记二(python3、Flask、uWSGI、Nginx)
从git上把项目拉到服务器,项目可以在服务器上运行后,就只需要配置uwsgi和nginx了.它们的逻辑关系是:外部请求->nginx->uwsgi->项目实例. 一.配置uwsgi ...
- js跨域上传文件 iframe
封装好的jq插件 (function () { var iframe = '<iframe name="jqUploadIframe" style="display ...
- js_微信分享,监听点击分享,分享成功,取消分享,分享失败回调
2017-06-13 见代码: function weixinShare() { var links = links = "www.youku.com"; common.get_o ...
- 【Python学习】解决pandas中打印DataFrame行列显示不全的问题
在使用pandas的DataFrame打印时,如果表太长或者太宽会自动只给前后一些行列,但有时候因为一些需要,可能想看到所有的行列. 所以只需要加一下的代码就行了. #显示所有列 pd.set_opt ...
- 【转】cve-2013-2094 perf_event_open 漏洞分析
cve-2013-2094是于2013年4月前后发现的linux kernel本地漏洞,该漏洞影响3.8.9之前开启了PERF_EVENT的linux系统.利用该漏洞,通过perf_event_ope ...
- WoW[www]
WoWBeez https://github.com/StealtheeEU/WoWBeez https://github.com/mtucker6784/Elysium https://github ...
- 利用python对WiderFace数据解析及画框
#注:此代码稍作修改也可以用于WFLW人脸数据集的标注文件解析,#参见其README.md文件了解其每一行的信息,从中解析出相应字#段即可. import os import cv2 def draw ...