Let it Bead
http://poj.org/problem?id=2409
// File Name: poj2409.cpp
// Author: bo_jwolf
// Created Time: 2013年10月08日 星期二 14: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, 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%lld", &c, &s ) != EOF ){
if( !c && !s )
break;
ans = polya();
printf( "%lld\n", ans );
}
return 0;
}
Let it Bead的更多相关文章
- 百练_2409 Let it Bead(Polya定理)
描述 "Let it Bead" company is located upstairs at 700 Cannery Row in Monterey, CA. As you ca ...
- poj 2049 Let it Bead(polya模板)
Description Cannery Row percent of the target audience insists that the bracelets be unique. (Just ...
- poj2409 Let it Bead
Let it Bead Time Limit: 1000MS M ...
- POJ1975 Median Weight Bead floyd传递闭包
Description There are N beads which of the same shape and size, but with different weights. N is an ...
- POJ 2409 Let it Bead(polya裸题)
题目传送:http://poj.org/problem?id=2409 Description "Let it Bead" company is located upstairs ...
- 【POJ2409】Let it Bead Pólya定理
[POJ2409]Let it Bead 题意:用$m$种颜色去染$n$个点的环,如果两个环在旋转或翻转后是相同的,则称这两个环是同构的.求不同构的环的个数. $n,m$很小就是了. 题解:在旋转$i ...
- POJ-1975 Median Weight Bead(Floyed)
Median Weight Bead Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3162 Accepted: 1630 De ...
- 珍珠 Median Weight Bead 977
描述 There are N beads which of the same shape and size, but with different weights. N is an odd numbe ...
- Median Weight Bead(最短路—floyed传递闭包)
Description There are N beads which of the same shape and size, but with different weights. N is an ...
- 珠排序Bead Sort
珠排序非常另类[地精也很另类],看完你就知道了,先介绍思路,再分解过程 这是它的英文论文 http://www.cs.auckland.ac.nz/~jaru003/research/publicat ...
随机推荐
- Spring通过SchedulerFactoryBean实现调度任务的配置
http://blog.csdn.net/hu_shengyang/article/details/19815201(里面是配置) 介绍SchedulerFactoryBean http://blog ...
- Jquery不生效
$(document).ready(function(){这个都没有生效, 1.网上查了说是jquery的路劲引入的有问题,经查并不是这个问题 2.换了一个jquery的版本,发现生效了. 原不生效文 ...
- Android手机修改Hosts的方法
Android手机是和Google帐号紧密联系的,由于中国的操蛋情况,很多时候Google帐号无法登录,导致Android市场无法使用. 在电脑上我们通过修改Hosts方法可以解决Google帐号的登 ...
- index full scan/index fast full scan/index range scan
**************************1************************************* 索引状态: valid. N/A . ...
- xcode7 icon图标设置
- OA系统权限管理设计方案学习
学习之:http://www.cnblogs.com/kivenhou/archive/2009/10/19/1586106.html 此为模型图: 据此写了sql语句: drop table if ...
- delegate 中的BeginInvoke和EndInvoke方法
开发语言:C#3.0 IDE:Visual Studio 2008 一.C#线程概述 在操作系统中一个进程至少要包含一个线程,然后,在某些时候需要在同一个进程中同时执行多项任务,或是为了提供程序的性能 ...
- 防止mysql注入
function check($sql_str) { $checks=eregi('select|insert|update|delete|\'|\/|\\\|\*|\.|union|into|loa ...
- jquery如何判断div是否隐藏--useful
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- sql的执行顺序
sql的一般执行顺序(8)SELECT (9)DISTINCT (11)<Top Num> <select list>(1)FROM [left_table](3)<jo ...