POJ 1286 Necklace of Beads Polya .
来源:互联网 发布:淘宝哪个领券app好用 编辑:程序博客网 时间:2024/05/12 08:43
题目地址:http://poj.org/problem?id=1286
旋转+翻转,裸的算法
#include<iostream>#include<cstdio>#include<cmath>using namespace std;typedef long long LL;int gcd(int a,int b){if(b==0) return a;return gcd(b,a%b);}int euler_phi(int n){int res=1;for(int i=2;i*i<=n;i++)if(n%i==0) { //说明i|nn/=i,res*=i-1;while(n%i==0) n/=i,res*=i; //说明i^2|n}if(n>1) res*=n-1;return res;}LL polya(int n){LL tot=0; //方案数 for(int i=1;i<=n;i++)tot+=pow(3,gcd(n,i));tot/=n;if(n%2!=0) tot+=pow(3,(n+1)/2); //oddelse tot+=(pow(3,n/2)+pow(3,n/2+1))/2;return tot/2;}int main(){int n;while(cin>>n&&n!=-1)if(n==0) cout<<0<<endl;else cout<<polya(n)<<endl;return 0;}
0 0
- POJ--1286[Necklace of Beads] Polya定理
- poj 1286 Necklace of Beads -----polya计数
- POJ 1286 Necklace of Beads Polya定理
- poj 1286 Necklace of Beads(Polya定理)
- poj 1286 Necklace of Beads (polya)
- poj 1286 Necklace of Beads polya计数
- poj 1286 Necklace of Beads (polya)
- poj 1286 Necklace of Beads 【polya计数】
- POJ 1286-Necklace of Beads(Polya计数)
- POJ 1286 Necklace of Beads(polya)
- POJ 1286 Necklace of Beads(Polya原理)
- POJ 1286 Necklace of Beads Polya .
- POJ 1286 Necklace of Beads (Polya)
- POJ 1286 Necklace of Beads && POJ 2409 Polya计数原理
- POJ 1286 Necklace of Beads(Polya简单应用)
- POJ 1286 Necklace of Beads(polya计数、burnside定理)
- POJ 题目1286 Necklace of Beads(Polya定理)
- poj Necklace of Beads 1286 (polya定理)置换群
- HDU 1517
- CCF201604-2 俄罗斯方块
- Linux下php安装memcache扩展
- Load Runner 压力测试总结
- Java回调机制(CallBack)详解
- POJ 1286 Necklace of Beads Polya .
- Android中常用UI组件总结
- Off the Wall
- 新建一个实例
- Android 高德地图的开发
- android 常用的功能
- Git使用和介绍-基础指令
- jdk-动态代理
- SpringMVC中使用Interceptor拦截器