POJ1286 Necklace of Beads(Polya定理)
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 9359 | Accepted: 3862 |
Description

Input
-1 denotes the end of the input file.
Output
Sample Input
4
5
-1
Sample Output
21
39
Source
哈哈我是来骗访问量的。这题和上一题一毛一样
只不过需要把颜色数改为$3$然后换成LLd
上一篇:https://www.cnblogs.com/zwfymqz/p/9294983.html
#include<algorithm>
#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int C = , N;
int fastpow(int a, int p) {
int base = ;
while(p) {
if(p & ) base = base * a;
a = a * a; p >>= ;
}
return base;
}
main() {
while(cin >> N) {
if(N == -) break;
if(N <= ) {printf("0\n"); continue;}
int ans = ;
for(int i = ; i <= N; i++) ans += fastpow(C, __gcd(i, N));
if(N & ) ans = ans + N * fastpow(C, (N + ) / );
else ans = ans + N / * (fastpow(C, (N + ) / ) + fastpow(C, N / ));
cout << ans / / N << endl;
}
}
POJ1286 Necklace of Beads(Polya定理)的更多相关文章
- poj1286 Necklace of Beads—— Polya定理
题目:http://poj.org/problem?id=1286 真·Polya定理模板题: 写完以后感觉理解更深刻了呢. 代码如下: #include<iostream> #inclu ...
- Necklace of Beads(polya定理)
http://poj.org/problem?id=1286 题意:求用3种颜色给n个珠子涂色的方案数.polya定理模板题. #include <stdio.h> #include &l ...
- 【数论】【Polya定理】poj1286 Necklace of Beads
Polya定理:设G={π1,π2,π3........πn}是X={a1,a2,a3.......an}上一个置换群,用m中颜色对X中的元素进行涂色,那么不同的涂色方案数为:1/|G|*(mC(π1 ...
- poj 1286 Necklace of Beads (polya(旋转+翻转)+模板)
Description Beads of red, blue or green colors are connected together into a circular necklace of ...
- Necklace of Beads(polya计数)
Necklace of Beads Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7451 Accepted: 3102 ...
- hdu 1817 Necklace of Beads (polya)
Necklace of Beads Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- poj1286 Necklace of Beads【裸polya】
非常裸的polya,只是我看polya看了非常久 吉大ACM模板里面也有 #include <cstdio> #include <cmath> #include <ios ...
- POJ1286 Necklace of Beads
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8263 Accepted: 3452 Description Beads ...
- POJ2154 Color【 polya定理+欧拉函数优化】(三个例题)
由于这是第一天去实现polya题,所以由易到难,先来个铺垫题(假设读者是看过课件的,不然可能会对有些“显然”的地方会看不懂): 一:POJ1286 Necklace of Beads :有三种颜色,问 ...
随机推荐
- 手机缺失sqlite3时操作数据库的多种解决方案 ----adb命令科普
在Android应用开发无处不在SQLite数据库的身影.那么在开发中怎么使用adb命令操作数据库的功能呢? 下面我们将完整的介绍与数据库操作相关的命令集及当手机缺少sqlite3的时候的多种解决方案 ...
- [原创]hibernate更新后jdbc读取不到数据问题
最近在做工作流插件时使用的是自己基于hibernate连接封装的orm框架,按说跟hibernate共用的一个连接,应该在同一个事务中,但在使用时hibernate saveOrUpdate后(未提交 ...
- DedeCMS {dede:field name='array' /}的用法
field支持用array获取任意字段的值.(支持标记:文章列表模板的 {dede:field name='array' /}.arclist.arclistsg.loop.sql 标签) 例如平 ...
- Cgroup blkio简介和测试(使用fio测试)
Cgroup blkio简介和测试(使用fio测试) 因需要对docker镜像内的进程对磁盘读写的速度进行限制,研究了下Cgroup blkio,并使用fio对其iops/bps限速进行测试. Cgr ...
- SpringBoot如何集成Jedis
添加jedis依赖 在项目pom.xml文件中添加依赖 <!-- 添加jedis依赖 --> <dependency> <groupId>redis.clients ...
- Tiled 地图编辑器使用教程-官方demo
一.Tiled Map Editer 下载地址 http://www.mapeditor.org/download.html 二.官方教程查看 下载安装后,不管windows还是Mac系统都包含官方例 ...
- js的垃圾收集机制以及写代码如何处理
程序都自己的内存,一旦内存过多就会清楚以前的缓存.所以,在写代码的时候,不要仅仅只会推变量到栈中,还要会将变量从栈中释放. 那么问题来了,我们应该如何将内存从栈中释放呢? 要释放变量,那就要从java ...
- JavaScript精简代码 非一般的写法(转载)
摘要:最近在编写一个前端模块功能,编写了大量的代码,其中一般图片特效展示是参考别人的代码来写的,发现有些代码似乎看得明白又好像不确定是不是哪个意思,所以在网上问了一下程序员们,原来是JS代码简写. 转 ...
- 【起航计划 024】2015 起航计划 Android APIDemo的魔鬼步伐 23 App->Notification->IncomingMessage 状态栏通知
应用程序可以使用Notifications来通知用户某个事件发生了(如收到短信).类NotificationManager 用来处理Notification, NotificationManager可 ...
- 【起航计划 012】2015 起航计划 Android APIDemo的魔鬼步伐 11 App->Activity->Save & Restore State onSaveInstanceState onRestoreInstanceState
Save & Restore State与之前的例子Android ApiDemo示例解析(9):App->Activity->Persistent State 实现的UI类似,但 ...