poj-2409(polya定理模板)
2015-01-27 16:41
323 查看
题意:给n种颜色和m个小球,问有多少种不同的方案!
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; int n, m; int gcd(int a, int b) { b = b % a; while (b) { a = a % b; swap(a, b); } return a; } int main() { while (scanf("%d%d", &n, &m), n | m) { int ans = 0; for (int i = 1; i <= m; i++) ans += pow(n, gcd(i, m));//旋转置换 if (m & 1) ans += m * pow(n, m / 2 + 1); else ans += m / 2 * pow(n, m / 2) + m / 2 * pow(n, m / 2 + 1);//翻转置换 ans /= m * 2; printf("%d\n", ans); } return 0; }
相关文章推荐
- poj 2409(polya定理模板)
- poj 2409(polya定理模板)
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
- poj 2409 Let it Bead(polya 定理)
- poj2409 等价类计数问题 polya定理
- poj 1286 和 2409 (polya 定理)
- POJ 2409 - Let it Bead【Polya定理】
- polya定理 和 置换 poj2409
- POJ 2409 Let it Bead(Polya定理)
- POJ_2409 Let it Bead(Polya定理)
- poj 2409 Let it Bead && poj 1286 Necklace of Beads(Polya定理)
- POJ 2409 Let it Bead (Polya定理)
- poj 2409 Let it Bead(polya定理)
- POJ 2409 Let it Bead (Polya定理)
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
- POJ 2409 Let it Bead polya 定理 和 置换
- POJ 2409-Let it Bead(Polya定理-旋转+翻转 串项链)
- POJ 2409 Let it Bead【polya 计数法,burnside定理】
- Let it Bead POJ - 2409 Polya定理
- 置换群Polya定理(poj 2409: Let it Bead)