http://poj.org/problem?id=1286

// File Name: poj1286.cpp
// Author: bo_jwolf
// Created Time: 2013年10月07日 星期一 21:31:08 #include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime> #define INT long long int using namespace std;
INT gcd( INT a, INT b){
return b == 0? a: gcd( b, a % b );
} INT c = 3, s;
INT polya(){
INT ans = 0;
for( INT i = 0; i < s; ++i ){
ans += (INT)pow( 1.0 * c, gcd( s, i ) );
}
if( s % 2 ){
ans += s * ( INT )pow( 1.0 * c, ( s / 2 + 1 ) );
}
else{
ans += s / 2 * ( INT )pow( 1.0 * c, s / 2 );
ans += s / 2 * ( INT )pow( 1.0 * c, s / 2 + 1 );
}
return ans / 2 / s;
} int main(){
INT ans;
while( scanf( "%lld", &s ) != EOF ){
if( s == -1 )
break;
if( s == 0 )
ans = 0;
else
ans = polya();
printf( "%lld\n", ans );
}
return 0;
}

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. Necklace of Beads(polya计数)

    Necklace of Beads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7451   Accepted: 3102 ...

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

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

  5. hdu 1817 Necklace of Beads(Polya定理)

    Necklace of Beads Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. hdu 1817 Necklace of Beads (polya)

    Necklace of Beads Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

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

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

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

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

  9. Necklace of Beads (polya定理的引用)

    Beads of red, blue or green colors are connected together into a circular necklace of n beads ( n &l ...

  10. POJ1286 Necklace of Beads

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8263   Accepted: 3452 Description Beads ...

随机推荐

  1. Notification和KVO有什么不同

    Notification是推送通知,我们可以建立一个通知中心,存放创建多个通知,在不同的地方在需要的时候push调用和KVO不同的是,KVO是键值观察,只能观察一个值,这就是区别

  2. 谢尔排序/缩减增量排序(C++)

    谢尔排序/缩减增量排序(C++) 谢尔排序/缩减增量排序: 他通过比较相距一定间隔的元素来工作,各趟比较所用的距离随着算法的进行而减小,直到只比较相邻元素的最后一趟排序为止.(好复杂) 看了一下实现代 ...

  3. Unity 5.x---00使用重力

    Unity 5.x---00使用重力 步骤一: 打开一个工程(导入Unity自带的资源),并创建并配置好必要的GameObject ,如下图: 步骤二: 1.创建一个Cube,使其位于平面上方.    ...

  4. java逻辑运算符&&、&、||、|的详解

    public class OperatorDemo{ public static void main(String args[]) { //当我们执行一下代码时会报错(&属于没短路的) if( ...

  5. U盘美化(更换U盘logo和页面背景软件)

    U盘内新建txt文本后,输入 [autorun] ICON=ooopic_1459309050.ico 保存的文件名包括后缀更改为autorun.inf 必须为icon图标

  6. 微信小程序,大多数人误解的8个问题

    作者:王安,数字天堂DCloud公司创始人兼CEO 注:本文内容包含技术.商业,不懂技术的读者可以只看商业相关的内容.本文仅代表作者一家之言,如有不同意见,欢迎留言讨论~ 8个误解 坊间所传的信息很多 ...

  7. C# ERP开发框架

    C/S系统开发框架-企业版 V4.0 (Enterprise Edition) 简介: http://www.csframework.com/cs-framework-4.0.htm 视频下载: 百度 ...

  8. 项目知识点.Part3

    内存管理: 基本数据类型或者Core Foundation对象都没有引用计数 主线程会自动创建释放池,子线程需要手动创建释放池. 具体的区别:http://www.cnblogs.com/langti ...

  9. spart快速大数据分析学习提纲(一)

    Spart是什么 Spart是一个用来实现快速而而通用的集群计算平台. 在速度方面,Spart扩展了广泛使用的Mapreduce计算模型,而且高效的支持更多的计算模式,包括交互式查询和流处理.Spar ...

  10. Python3 time()

    在<Python基础教程(第二版)>一书中, if time % 60 == 0 : print 'on the hour! '在3.3.2版本中显示错误.于是自己查了一下帮助文档,也在网 ...