数学计数原理(Pólya):POJ 1286 Necklace of Beads
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 7763 | Accepted: 3247 |
Description

Input
-1 denotes the end of the input file.
Output
Sample Input
- 4
- 5
- -1
Sample Output
- 21
- 39
公式是这样子的:
p是颜色数,这里等于3,可以发现这2*n个置换形成了置换群,满足了群的封闭性。
那么只要对于每个置换找不动点就好了…… http://www.cnblogs.com/TenderRun/p/5656038.html 循环的部分和这题类似
- #include <iostream>
- #include <cstring>
- #include <cstdio>
- using namespace std;
- long long pow[],phi[],n,ans;
- long long Gcd(long long a,long long b){
- return b?Gcd(b,a%b):a;
- }
- int main(){
- pow[]=;
- for(int i=;i<=;i++)
- pow[i]=pow[i-]*;
- for(int i=;i<=;i++)
- for(int j=i;j>=;j--)
- if(Gcd(i,j)==)phi[i]+=;
- while(scanf("%lld",&n)!=EOF&&n!=-){
- if(n==){printf("0\n");continue;}
- for(int d=;d<=n;d++)
- if(n%d==)ans+=phi[n/d]*pow[d];
- if(n%)ans=(ans+n*pow[(n+)/])//n;
- else ans=(ans+n/*(pow[n/+]+pow[n/]))//n;
- printf("%lld\n",ans);ans=;
- }
- }
数学计数原理(Pólya):POJ 1286 Necklace of Beads的更多相关文章
- poj 1286 Necklace of Beads & poj 2409 Let it Bead(初涉polya定理)
http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...
- POJ 1286 Necklace of Beads(项链的珠子)
Necklace of Beads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7874 Accepted: 3290 ...
- poj 1286 Necklace of Beads poj 2409 Let it Bead HDU 3923 Invoker <组合数学>
链接:http://poj.org/problem?id=1286 http://poj.org/problem?id=2409 #include <cstdio> #include &l ...
- POJ 1286 Necklace of Beads(Polya简单应用)
Necklace of Beads 大意:3种颜色的珠子,n个串在一起,旋转变换跟反转变换假设同样就算是同一种,问会有多少种不同的组合. 思路:正规学Polya的第一道题,在楠神的带领下,理解的还算挺 ...
- POJ 1286 Necklace of Beads(Polya原理)
Description Beads of red, blue or green colors are connected together into a circular necklace of n ...
- poj 2409 Let it Bead && poj 1286 Necklace of Beads(Polya定理)
题目:http://poj.org/problem?id=2409 题意:用k种不同的颜色给长度为n的项链染色 网上大神的题解: 1.旋转置换:一个有n个旋转置换,依次为旋转0,1,2,```n-1. ...
- poj 1286 Necklace of Beads (polya(旋转+翻转)+模板)
Description Beads of red, blue or green colors are connected together into a circular necklace of ...
- poj 1286 Necklace of Beads【polya定理+burnside引理】
和poj 2409差不多,就是k变成3了,详见 还有不一样的地方是记得特判n==0的情况不然会RE #include<iostream> #include<cstdio> us ...
- poj 1286 Necklace of Beads
这是做的第一道群论题,自然要很水又很裸.注意用long long. 就是用到了两个定理 burnside :不等价方案数=每个置换的不动置换方案数的和 / 置换个数 polya: 一个置换的不动置换方 ...
随机推荐
- C++链表与键值对
<算法>一书中,在算法3.1中提到了Map的实现,这里根据书上的思想,用单向链表简单写了写. #ifndef SEQUENTIAL_H #define SEQUENTIAL_H templ ...
- 第四篇:python 高级之面向对象初级
python 高级之面向对象初级 python 高级之面向对象初级 本节内容 类的创建 类的构造方法 面向对象之封装 面向对象之继承 面向对象之多态 面向对象之成员 property 1.类的创建 ...
- MVC ViewEngine视图引擎解读及autofac的IOC运用实践
MVC 三大特色 Model.View.Control ,这次咱们讲视图引擎ViewEngine 1.首先看看IViewEngine接口的定义 namespace System.Web.Mvc { ...
- oracle 导出导入数据
在window的运行中输出cmd,然后执行下面的一行代码, imp blmp/blmp@orcl full=y file=D:\blmp.dmp OK,问题解决.如果报找不到该blmp.dmp文件,就 ...
- Web Service属性介绍
每个 Web Service都需要唯一的命名空间,它可使客户端应用程序区分出可能使用相同方法名称的 Web Service.在 Visual Studio.NET中创建的Web Service的默认命 ...
- mybatis for .net
MyBatis For .NET学习笔记:开篇 http://chenkai.blog.51cto.com/2023960/763806 MyBatis For .NET学习笔记[2]:配置环境 ht ...
- 最简单的基于FFmpeg的移动端例子:IOS 视频解码器-保存
===================================================== 最简单的基于FFmpeg的移动端例子系列文章列表: 最简单的基于FFmpeg的移动端例子:A ...
- iOS、mac开源项目及库汇总
原文地址:http://blog.csdn.net/qq_26359763/article/details/51076499 iOS每日一记------------之 中级完美大整理 iOS.m ...
- iOS自动布局之autoresizingi
对于iOS的app开发者来说,不会像Android开发者一样为很多的屏幕尺寸来做界面适配,因此硬编码的坐标也能工作良好,但是从设计模式上来说这不是好的做法.而且也还有一些问题,如iPhone5的适配, ...
- 《find技巧》-“linux命令五分系列”之一
一天一个命令,做个记录, 我要成大神,哈哈哈 本原创文章属于<Linux大棚>博客. 博客地址为http://roclinux.cn. 文章作者为roc 希望您能通过捐款的方式支持Linu ...