poj 2409 Let it Bead Polya计数
来源:互联网 发布:shell编程入门书籍推荐 编辑:程序博客网 时间:2024/05/20 09:46
旋转可以分为n种置换,对应的循环个数分别是gcd(n,i),个i=0时不动,有n个
翻转分为奇偶讨论,奇数时有n种置换,每种有n/2+1个
偶数时有n种置换,一半是n/2+1个,一半是n/2个
啃论文,PPT,各种书好久才看懂Polya定理,最近做数学题做的严重怀疑自己的智商。
#include <iostream>#include <cstdio>#include <cstdlib>#include<algorithm>#include<map>#include<cstring>using namespace std;typedef long long ll;ll gcd(ll a,ll b) {return a%b==0?b:gcd(b,a%b);}ll quickpow(ll m,ll n){ ll ans=1; while(n) { if(n&1) ans=ans*m; n=(n>>1); m=m*m; } return ans;}int main(){ ll c,n; while(~scanf("%lld%lld",&c,&n)) { if(c+n==0) break; ll ans=quickpow(c,n); for(int i=1;i<n;i++) ans+=quickpow(c,gcd(n,i)); if(n&1) ans+=n*quickpow(c,n/2+1); else ans+=(n/2*quickpow(c,n/2+1)+n/2*(quickpow(c,n/2))); printf("%lld\n",ans/(2*n)); } return 0;}
4 0
- POj 2409 Let it Bead ----- polya计数
- poj 2409 Let it Bead Polya计数
- POJ 2409-Let it Bead(Polya计数)
- POJ 2409 Let it Bead (Polya计数)
- [ACM] POJ 2409 Let it Bead (Polya计数)
- POJ 2409 Let it Bead (Polya计数)
- POJ 2409 Let it Bead (polya计数)
- POJ 2409 Let it Bead (polya计数,burnside染色)
- POJ 2409 Let it Bead Polya定理
- POJ 2409 Let it bead 【裸polya】
- poj 2409 Let it Bead (polya)
- POJ 2409 - Let it Bead【Polya定理】
- POJ 2409 Let it Bead ACM Polya
- POJ 2409 Let it Bead(polya)
- 【POJ 2409】 Let it Bead(Polya)
- [Polya] POJ 2409 Let it Bead
- POJ 2409 Let it Bead (Polya) .
- poj 2409 Let it Bead Polya定理
- Charm Bracelet
- Circular RMQ
- 无线wifi
- Boost中文件系统类FileSystem全面解析
- Tomcat服务器的主要目录结构:
- poj 2409 Let it Bead Polya计数
- 这样0后言文塞一位优
- poj 2965 The Pilots Brothers' refrigerator
- 关于c语言的想法探究1(新手,给自己看的)
- 蝉知门户系统迁移到SAE平台-浏览目录空间
- 汉诺塔系列问题: 汉诺塔II、汉诺塔III、汉诺塔IV、汉诺塔V、汉诺塔VI、汉诺塔VII
- 【剑指offer】Q9:斐波那契数列
- Scrapy 安装
- 饭卡