POJ-1284-Primitive Roots 解题报告
来源:互联网 发布:面板数据和混合数据 编辑:程序博客网 时间:2024/06/06 10:06
欧拉函数水题。题意:给出原根的定义,求模p的原根的个数。
我的解题思路:根据原根的性质,模p的原根个数为phi(phi(p)),直接求两次欧拉函数就好。
我的解题代码:
#include <cstdio>#include <cstdlib>#include <cstring>#include <cctype>#include <cmath>#include <climits>#include <algorithm>using namespace std;int Phi(int x);int main(){ int m; while (~scanf("%d", &m)) { printf("%d\n", Phi(Phi(m))); } return 0;}int Phi(int x){ int ans = x; int cnt = (int)sqrt(x + 0.5) + 1; for (int i=2; i<cnt; ++i) { if (x % i == 0) { ans -= ans / i; while (x % i == 0) x /= i; } } if (x > 1) ans -= ans / x; return ans;}
0 0
- POJ-1284-Primitive Roots 解题报告
- POJ 1284 Primitive Roots 解题报告(欧拉函数)
- POJ 1284 Primitive Roots
- poj - 1284 - Primitive Roots
- Poj 1284 Primitive Roots
- 【POJ 1284】Primitive Roots
- POJ 1284 primitive roots
- POJ 1284Primitive Roots
- POJ 1284 Primitive Roots
- poj 1284 Primitive Roots
- POJ-1284-Primitive Roots
- POJ 1284 Primitive Roots(素数原根)
- poj 1284——Primitive Roots
- POJ 1284 Primitive Roots (求原根个数)
- poj 1284 Primitive Roots 【原根】【数论】
- POJ 1284 Primitive Roots 原根
- poj 1284 Primitive Roots 求素数元根数
- POJ 1284 Primitive Roots (原根)
- TreeMap源码导读
- 2014年个人工作总结(补发)
- 数据挖掘十大经典算法(9) 朴素贝叶斯分类器 Naive Bayes
- 理解Fragment生命周期
- Android开发性能优化大总结
- POJ-1284-Primitive Roots 解题报告
- Android 自定义 ViewPager 打造千变万化的图片切换效果
- 数据挖掘十大经典算法(10) CART: 分类与回归树
- 工作周报035
- Linux之make的用法讲解
- ******************** 整型变量的修饰符 ********************
- Android异步消息处理机制(一):理解 Looper、Handler、Message三者间关系
- 跳台阶问题
- 第三周项目5-1:数组作数据成员