POJ 1286 解题报告
来源:互联网 发布:中国历史地名数据库 编辑:程序博客网 时间:2024/05/20 00:12
这道题是Polya题。我第一次接触到这个定理。看了别人的解题报告做的这道题:
看过的最好的解释:http://www.cnblogs.com/mcflurry/archive/2012/06/20/2556071.html
ACM中的数学问题:http://www.doc88.com/p-910707819004.html (莫名其妙的打不开50页之后的PPT)http://wenku.baidu.com/view/b1eb7cfdaef8941ea76e05f4.html
还是不清楚轮换个数(循环节)的求法,再遇到再深入吧。
这里,long long的表示空间比double大,因为我们没有小数部分。
thestoryofsnow1286Accepted208K0MSC++1317B/* ID: thestor1 LANG: C++ TASK: poj1286 */#include <iostream>#include <fstream>#include <cmath>#include <cstdio>#include <cstring>#include <limits>#include <string>#include <vector>#include <list>#include <set>#include <map>#include <queue>#include <stack>#include <algorithm>#include <cassert>using namespace std;int gcd(int a, int b) {while (b != 0) {int r = a % b;a = b;b = r;}return a;}// Polya: http://wenku.baidu.com/view/b1eb7cfdaef8941ea76e05f4.html// S = (m^c_1 + m^c_2 + ... + m^c_G) / |G|// Analysis: http://www.cnblogs.com/mcflurry/archive/2012/06/20/2556071.htmlint main(){int n;while (scanf("%d", &n) > 0 && n >= 0) {// edge caseif (n == 0) {printf("0\n");continue;}long long ans = 0;// rotationfor (int i = 0; i < n; ++i) {ans += pow(3.0, (double)gcd(i, n));}// reflectionif (n & 1) {// if oddans += n * pow(3.0, (double) (n - 1) / 2 + 1);} else {// if even// the axis of symmetry is the line between a point and its opposite pointans += n / 2 * pow(3.0, (double) (n - 2) / 2 + 2);// the axis of symmetry is the line between the middle of two adjcent points and its oppositeans += n / 2 * pow(3.0, (double) n / 2);}printf("%lld\n", ans / (2 * n));}return 0; }
0 0
- poj 1286解题报告
- POJ 1286 解题报告
- poj数百篇解题报告
- poj 1141解题报告
- poj 1001解题报告
- poj 1011 解题报告
- poj 1087 解题报告
- poj 2153解题报告
- poj 2051解题报告
- POJ 1167 解题报告
- poj 1026 解题报告
- POJ 1077 解题报告
- POJ 1042 解题报告
- POJ 1095 解题报告
- POJ 1159解题报告
- poj 2312解题报告
- POJ 1001解题报告
- POJ 1002解题报告
- Android OkHttp完全解析 是时候来了解OkHttp了
- git push -u origin XXX 报错
- 【HTML5】H5的新标签简介
- 横竖屏切换和contentView的三种显示方式
- Java 多线程编程
- POJ 1286 解题报告
- CSS-float
- linux下的压缩和解压缩的命令总结
- aodv之二
- object-c第三方FMDB对sqlite使用
- 20160322 股票入门
- 进阶级-正则表达式
- 多线程中的join(),yield()与优先级Priority
- SAP主数据字段前导零 策略