#include <iostream> #include <math.h> using namespace std; #define LL long long LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; } LL polya(LL n) { LL ret = ; ; i < n; i++) ret += pow(, gcd(i, n)); //flip them... )//odd ret += n * pow(, n…
Color Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7630 Accepted: 2507 Description Beads of N colors are connected together into a circular necklace of N beads (N<=1000000000). Your job is to calculate how many different kinds of th…
Let it Bead Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5365 Accepted: 3585 Description "Let it Bead" company is located upstairs at 700 Cannery Row in Monterey, CA. As you can deduce from the company name, their business is b…
Different Circle Permutation Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 218 Accepted Submission(s): 106 Problem Description You may not know this but it's a fact that Xinghai Square is…
Birthday Toy Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 644 Accepted Submission(s): 326 Problem Description AekdyCoin loves toys. It is AekdyCoin’s Birthday today and he gets a special “…
Who's Aunt Zhang Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 19 Accepted Submission(s): 16 Problem Description Aunt Zhang, well known as 张阿姨, is a fan of Rubik’s cube. One day she buys a…
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 axis of symmetry ar…
Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < ). If the repetitions that are produced by rotation around the center of the circular necklace or reflection to the axis of symmetry are…
和poj 2409差不多,就是k变成3了,详见 还有不一样的地方是记得特判n==0的情况不然会RE #include<iostream> #include<cstdio> using namespace std; long long n,ans; long long ksm(long long a,long long b) { long long r=1; while(b) { if(b&1) r=r*a; a=a*a; b>>=1; } return r; }…
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…
Necklace of Beads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7763 Accepted: 3247 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 pro…
参考:https://blog.csdn.net/sr_19930829/article/details/38108871 #include <iostream> #include <string.h> using namespace std; int c,n;//c种颜色,n个珠子 int ans; int gcd(int a,int b) { ?a:gcd(b,a%b); } int power(int p,int n)//快速幂求公式里的k的nc(g)次方 { ; while…
题目链接: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(…
Necklace of Beads Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1817 Description Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n < 40 ). If…