polya定理 poj2409 Let it Bead
来源:互联网 发布:灰土环刀取样数据 编辑:程序博客网 时间:2024/06/06 21:06
很经典的一道polya定理的题目,,以前看到这种具有对称性求个数的题目完全没法动。学了polya定理就能愉快的玩耍了。
polya定理很容易用,,大概就是一个这样的规律,先把所有的变换后颜色不变的情况写出来,比如这题就是:
1.如果旋转1下,前后颜色都不变
2.如果旋转2下,前后颜色都不变
........
n.如果旋转n下,前后颜色都不变
如果n是奇数,且对着每条角平分线对折,前后颜色都不变
如果n是偶数
--| 如果对着每条角平分线对折,前后颜色都不变
--| 如果对着边的中垂线对折,前后颜色都不变
把这些情况的数量都算出来,然后相加,除以总情况数,,就是答案了
polya定理很容易用,,大概就是一个这样的规律,先把所有的变换后颜色不变的情况写出来,比如这题就是:
1.如果旋转1下,前后颜色都不变
2.如果旋转2下,前后颜色都不变
........
n.如果旋转n下,前后颜色都不变
如果n是奇数,且对着每条角平分线对折,前后颜色都不变
如果n是偶数
--| 如果对着每条角平分线对折,前后颜色都不变
--| 如果对着边的中垂线对折,前后颜色都不变
把这些情况的数量都算出来,然后相加,除以总情况数,,就是答案了
#include<cstdio>#include<cmath>#include<cstring>#include<queue>#include<vector>#include<map>#include<string>#include<iostream>#include<functional>#include<algorithm>using namespace std;typedef long long LL;typedef pair<int, int> PII;const int MX = 2000 + 5;LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a;}LL power(LL a, LL b) { LL ret = 1; while(b) { if(b & 1) ret *= a; a *= a; b >>= 1; } return ret;}int main() { int m, n; //freopen("input.txt","r",stdin); while(~scanf("%d%d", &m, &n), m + n) { LL ans = 0; for(int d = 1; d <= n; d++) { ans += power(m, gcd(n, d)); } if(n % 2 == 0) { ans += n / 2 * power(m, n / 2); ans += n / 2 * power(m, (n + 2) / 2); }else{ ans += n * power(m, (n + 1) / 2); } printf("%I64d\n", ans / n / 2); } return 0;}
0 0
- poj2409 Let it Bead polya定理
- polya定理 poj2409 Let it Bead
- POJ2409 Let it Bead【Polya定理】
- POJ2409--Let it Bead--Polya
- poj2409 Let it Bead
- poj2409 Let it Bead
- POJ2409 Let it Bead
- poj2409--Let it Bead(置换群+polya奇数)
- 2409 Let it Bead //polya 定理
- POJ 2409 Let it Bead Polya定理
- POJ 2409 - Let it Bead【Polya定理】
- poj 2409 Let it Bead Polya定理
- poj2409 Let it Bead(置换)
- poj 2409 Let it Bead(polya定理)
- POJ 2409 Let it Bead polya 定理 和 置换
- 【裸polya定理】poj 2409 Let it Bead
- poj 2409 Let it Bead Polya波利亚定理
- poj 2409 Let it Bead(polya 定理)
- 不要做浮躁的嵌入式系统工程师
- No UserDatabase component found under key UserDatabase(tomcat启动报错)
- MySQL初学者入门教程
- windows7 32位如何安装python 的scikiet-learn机器学习包问题
- 认真学spring官网,很容易找到spring4的jar包下载位置
- polya定理 poj2409 Let it Bead
- iOS 屏幕适配,autoResizing autoLayout和sizeClass图文详解
- 【ES6系列】ES6简介
- Unable to convert data to string around character 11.
- 代码生成器:Java自动生成service,serviceImpl及action
- 使用POI在线预览Word
- 南邮 OJ 1053 恶魔城
- java单分派与多分派(多路分发和单路分发)
- Android仿qq聊天记录长按删除功能效果