poj 2409(polya定理模板)
2015-12-30 21:04
357 查看
旋转加翻转
#include <iostream> #include <string.h> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; #define maxn 1200 #define eps 1e-8 int gcd(int n,int m) { if (m == 0) { return n; } return gcd(m,n%m); } int c,s; int main() { while (cin>>c>>s&&c&&s) { long long ans = 0; for (int i = 1; i<=s; i++) { ans += pow(c, gcd(s, i)); } if (s&1) { ans += s*pow(c, s/2+1); } else ans += s/2*pow(c, (s+2)/2)+s/2*pow(c, s/2); ans /= s*2; cout<<ans<<endl; } return 0; }
相关文章推荐
- QT怎样在QTableWidge显示图片
- [二]Ajax基本实现
- 标签分类
- 记录我的前端之路
- 【每日一剂】---onSaveInstanceState()保存临时数据
- 如何改变<input type=”text" >输入框内的值
- HDU 2019
- 大数据成长历程
- 使用fstream输出数据到.txt文件
- 12月30号 iOS程序准备
- 读取注册表hive文件
- 深入分析JavaWeb Item40 -- 文件上传和下载
- linux下串口调试工具/串口终端推荐: picocom
- mac 中npm安装模块去除sudo
- C语言的判断语句
- [nginx+tomcat的负载均衡搭建] This system is not registered with RHN
- Brocade SAN Switch CFG backup and recover
- Codeforce 题目479E Riding in a Lift(DP)
- Java中的String为什么是不可变的? -- String源码分析
- 你还不知道?这四个因素决定了你的养老金待遇!