Poj 1284 Primitive Roots
来源:互联网 发布:金山数据恢复 收费 编辑:程序博客网 时间:2024/05/29 13:44
题目链接:点击打开链接
题目的意思就是给一个odd prime,要你求其原根个数。
根据原根个数定理:
如果有一个数p有原根的话,那么p的原根个数为Euler(Euler(p));
对于该题目:由于给定是一个奇素数,所以Euler(p)=p-1;
所以answer=Euler(p-1)。
代码:
#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#define LL long longLL Euler1(LL n){ LL ans=n; for(LL i=2;i<=sqrt(n);i++){ if(n%i==0){ while(n%i==0) n=n/i; ans=ans/i*(i-1); } } if(n>1) ans=ans/n*(n-1); return ans;}int main(){ LL n; while(~scanf("%lld",&n)){ printf("%lld\n",Euler1(n)); } return 0;}
不能够系统的学习,那就慢慢的积累吧。!!
0 0
- 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 求素数元根数
- POJ 1284 Primitive Roots (原根)
- POJ 1284 Primitive Roots(欧拉函数)
- mongoose 数据库操作3
- 《从程序员到项目经理》读书笔记(八):程序员加油站 -- 再牛也要合群
- css进阶
- VS2010编译Lua程序
- [POJ 2104] K-th Number [块状链表]
- Poj 1284 Primitive Roots
- c++源代码:拷贝文件
- Windows环境下我常用的命令
- 信息安全的深度与广度思考
- 复杂的心情
- Block知识深入
- awk命令学习
- poj 3779 Single CPU, multi-tasking(模拟)
- 手机网页插件精选--触摸日期选择、触摸列表