POJ 1284 Primitive Roots(素数原根)
来源:互联网 发布:淘宝仓库 编辑:程序博客网 时间:2024/06/06 04:10
原根概念:设m是正整数,a是整数,若a模m的阶等于φ(m),则称a为模m的一个原根。(其中φ(m)表示m的欧拉函数)
本题需应用的结论:若p是一个素数,则p有φ(p-1)个原根。
#include <iostream>using namespace std;const int maxn =10000+5;int ph(int x){ int ans=x; for(int i=2;i*i<=x;i++) if(x%i==0){ ans=ans/i*(i-1); while(x%i==0) x/=i; } if(x>1) ans=ans/x*(x-1); return ans;}int main(){ int n; while(cin>>n){ cout<<ph(n-1)<<endl; } return 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 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
- paip.手机时间设置不能修改灰色禁用 解决大法
- ThreeColorabilityEasy
- 网站设计必须要考虑的用户体验
- Spring对事务管理的支持的发展历程(基础篇)
- oracle编译数据库失效对象
- POJ 1284 Primitive Roots(素数原根)
- C#利用NPOI在同一个Excel文件中创建多个sheet
- RHEL6.4_64安装单实例ORACLE12cR1
- 数据库学习初体验
- 邮件列表的礼仪
- 二本通信专业学生的嵌入式之路
- UVA 331 Mapping the Swaps (回溯+dfs)
- 多线程技术C#
- 热备小结