poj 2409 Let it Bead(polya)
来源:互联网 发布:图片html源码怎么看 编辑:程序博客网 时间:2024/06/05 20:16
m种颜色给n个珠子染色,n个珠子围成了一圈,具有对称性的计数,裸的polya。
#include <stdio.h>int m,n;int gcd(int a, int b){ if(b == 0) return a; return gcd(b,a%b);}int pow(int a, int b){ int ret = 1; while(b) { if(b&1) ret = ret*a; a = a*a; b >>= 1; } return ret;}int main(){ int sum; while(scanf("%d %d",&m,&n) && m+n) { sum = 0; //n种旋转的情况 for(int i = 1; i <= n; ++i) { int tmp = gcd(n,i); sum += pow(m,tmp); } //反转的情况 if(n&1) sum += n*pow(m,(n+1)/2); else { sum += (n/2)*pow(m,(n+2)/2); sum += (n/2)*pow(m,n/2); } sum = sum/(2*n);//旋转有n个置换,翻转有n个置换 printf("%d\n",sum); } return 0;}
阅读全文
0 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计数
- 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定理
- 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 polya 定理 和 置换
- 设计模式C++实现(11)——装饰模式
- Android开发 sharesdk分享微信/朋友圈的时候只显示文字,不显示链接
- C/C++实现strcpy和strcat两个功能
- Java多线程的两种实际应用
- android中捕获全局异常
- poj 2409 Let it Bead(polya)
- VMware虚拟机过卡-解决办法(Win10系统)
- 关系型数据库与非关系型数据库的区别?
- 使用阿里云ecs搭建网站
- mysql 下计算两点经纬度之间的距离
- hdu 1231 最大连续子序列
- 【codechef】Fibonacci Numbers on Tree
- 前端技能树
- POJ 1065 && HDU 1051 Wooden Sticks 贪心