这是做的第一道群论题,自然要很水又很裸。注意用long long。

就是用到了两个定理

burnside :不等价方案数=每个置换的不动置换方案数的和 / 置换个数

polya: 一个置换的不动置换方案数=k^(这个置换的循环个数)

先看第一个博客再看第二个

http://cxjyxx.me/?p=198

http://endlesscount.blog.163.com/blog/static/82119787201221324524202/

这两个蛮好的,上代码:

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std; int n; long long mi(int a)
{
long long ans = , zan = ;
while (a)
{
if (a & ) ans *= zan;
zan *= zan;
a >>= ;
}
return ans;
} int gcd(int a, int b)
{
if (!b) return a;
return gcd(b, a%b);
} int main()
{
scanf("%d", &n);
while (n != -)
{
if (n == )
{
printf("0\n");
scanf("%d", &n);
continue;
}
int Gcount = *n;
long long ans = ;
for (int i = ; i <= n; ++i)
ans += mi(gcd(i,n));
if (n % == ) ans += mi(n/)*n/ + mi(n/+)*n/;
else ans += mi(n/+)*n;
printf("%I64d\n", ans / Gcount);
scanf("%d", &n);
}
return ;
}

poj 1286 Necklace of Beads的更多相关文章

  1. 数学计数原理(Pólya):POJ 1286 Necklace of Beads

    Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7763   Accepted: 3247 ...

  2. POJ 1286 Necklace of Beads(项链的珠子)

    Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7874   Accepted: 3290 ...

  3. poj 1286 Necklace of Beads &amp; poj 2409 Let it Bead(初涉polya定理)

    http://poj.org/problem?id=1286 题意:有红.绿.蓝三种颜色的n个珠子.要把它们构成一个项链,问有多少种不同的方法.旋转和翻转后同样的属于同一种方法. polya计数. 搜 ...

  4. POJ 1286 Necklace of Beads(Polya简单应用)

    Necklace of Beads 大意:3种颜色的珠子,n个串在一起,旋转变换跟反转变换假设同样就算是同一种,问会有多少种不同的组合. 思路:正规学Polya的第一道题,在楠神的带领下,理解的还算挺 ...

  5. 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 ...

  6. POJ 1286 Necklace of Beads(Polya原理)

    Description Beads of red, blue or green colors are connected together into a circular necklace of n ...

  7. 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. ...

  8. poj 1286 Necklace of Beads (polya(旋转+翻转)+模板)

      Description Beads of red, blue or green colors are connected together into a circular necklace of ...

  9. poj 1286 Necklace of Beads【polya定理+burnside引理】

    和poj 2409差不多,就是k变成3了,详见 还有不一样的地方是记得特判n==0的情况不然会RE #include<iostream> #include<cstdio> us ...

随机推荐

  1. cocos2dx3.2 画图方法小修改之 C++ final学习

    今天用cocos2dx 3.2版本号学习画图功能,       于是我重载Node 的draw方法.发现报错, watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQ ...

  2. ROR 环境的 搭建

    1)安装RUBY:从 http://www.ruby-lang.org/en/ 下载 ruby182-15.exe,安装Ruby.ruby -v 看是否安装成功.2)安装RAILS框架 :gem in ...

  3. btn控件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  4. 分布式文件系统之GPFS

    GPFS是IBM公司通过完善和发展其Tiger Shark文件系统发展而来.GPFS通过共享磁盘结构来实现其强大的扩展性.一个GPFS系统由许多集群节点组成,GPFS文件系统和应用程序在上面运行.这些 ...

  5. 组合数学poj 1496 1850 同样的代码过两题

    Description   1942 Transmitting and memorizing information is a task that requires different coding ...

  6. 大四找实习(web前端),加油

    大四很奇妙,课程变少了,事情却繁杂了. 大三暑假去学驾照,在很多人看来太迟了(毕竟身边很多人跑去实习了),包括我自己.学驾照特别费时间,尤其是对即将大四,希望用实习充实自己的我来说.考虑再三,终于决定 ...

  7. 渐进式jpeg(progressive jpeg)图片及其相关 --图片的两种加载方式

    渐进式jpeg(progressive jpeg)图片及其相关   一.基本JPEG(baseline jpeg)和渐进JPEG 网络上那些色色的照片都是.jpg格式的("色色"指 ...

  8. 关于环信的WebIm的SDK一些使用注意

    先打自己几下脸,不好好看接口文档,啪啪啪. 主要先说下回调,直接先copy文档的 conn.listen({ onOpened: function ( message ) { //连接成功回调 //以 ...

  9. python 元类——metaclass

    from stack overflow:http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python Classes ...

  10. Java Concurrency - wait & notify, 等待通知机制

    生产者消费者问题是一个常见的多线程同步案例:一组生产者线程和一组消费者线程共享一个初始状态为空.大小为 N 的缓冲区.只有当缓冲区没满的时候,生产者才能把消息放入缓冲区,否则必须等待:只有缓冲区不空的 ...