题目链接:http://poj.org/problem?id=2409 题意:输入 m, n 表示有 m 种颜色,要构造一个长度为 n 的手环,旋转和对称的只算一种,问能组成多少个不同的手环. 思路:polya 模板 详见:http://m.blog.csdn.net/thchuan2001/article/details/65653855 代码: #include <iostream> #include <math.h> using namespace std; int gcd(…
题意:给你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;…
http://poj.org/problem?id=1286 题意:求用3种颜色给n个珠子涂色的方案数.polya定理模板题. #include <stdio.h> #include <math.h> long long gcd(long long a,long long b) { return b?gcd(b,a%b):a; } int main() { long long n; while(~scanf("%lld",&n)) { ) break;…
Necklace of Beads Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 24 ). If the repetitions that are produced by rotation around the center of the circular necklace or reflection to the a…