poj1286(polya计数 套模版)
来源:互联网 发布:js调用身份证读取器 编辑:程序博客网 时间:2024/06/01 09:53
http://poj.org/problem?id=1286 return b?gcd(b,a%b):a; int c=3,s; while(scanf("%d",&s)!=EOF) { if(s==0)//关键 { printf("0\n"); continue; } if(s==-1) { break; } intk; long longp[64]; p[0]=1; for(k=0;k { p[k+1]=p[k]*c; } long longcount=s&1?s*p[s/2+1]:(s/2)*(p[s/2]+p[s/2+1]); for(k=1;k<=s;k++) { count+=p[gcd(k,s)]; } count/=2*s; printf("%lld\n",count); } return 0;
Necklace ofBeads
Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 5318Accepted: 2203
Description
Beads of red, blueor green colors are connected together into a circular necklace ofn beads ( n < 24 ). If the repetitions that are produced byrotation around the center of the circular necklace or reflectionto the axis of symmetry are all neglected, how many different formsof the necklace are there?
Input
The input hasseveral lines, and each line contains the input data n.
-1 denotes the end of the input file.
-1 denotes the end of the input file.
Output
The output shouldcontain the output data: Number of different forms, in each linecorrespondent to the input data.
Sample Input
45-1
Sample Output
2139
Source
Xi'an2002
和poj2409一样,直接照搬就行了,具体解题报告参看上一篇文章。。
注意点:他只输入n,而且颜色数量只有3钟,然后又不去模。所以不用考虑逆元什么的
有两点要注意:
1、n=32的时候答案其实已经超过int了,要用int64才能装得下
2、n=0的时候答案不是1而是0(这个地方re了好多次啊)。。。
#include
#include
#include
using namespacestd;
int gcd(int a,intb)
{
}
int main()
{
}
- poj1286(polya计数 套模版)
- poj2409(polya计数 套模版)
- poj1286-polya计数、burnside定理
- poj1286 Necklace of Beads polya计数
- Polya.poj1286
- poj1286--Necklace of Beads(置换群+polya计数)
- polya计数模版题总结
- polya定理 poj1286 poj2409
- Polya计数
- Polya计数
- poj1286 Necklace of Beads(polya定理)
- POJ1286:Necklace of Beads(POLYA定理应用)
- poj1286 Necklace of Beads【裸polya】
- POJ1286 Necklace of Beads【Polya定理】
- (带讲解)poj2409&poj1286 polya模板
- poj1286 Necklace of Beads【polya定理】
- 【hdu3441】Rotation,Polya套Polya
- [ACM] POJ 1286 Necklace of Beads (Polya计数,直接套公式)
- poj1850(组合数学)
- poj1496(组合数学)-与1850几乎一样
- cf141div2
- 组合数学知识点
- poj2409(polya计数 套模版)
- poj1286(polya计数 套模版)
- 快捷方式引起的home键问题
- 数据结构_栈实现数值转换
- 教大家快捷的生成和解析xml
- poj2249(排列组合__套模板)
- hdu 1730 Northcott Game
- 《C++ Primer》读书笔记(6.5,6.8,6.11)
- poj1833(排列组合)
- poj2748(找规律)