POJ1284 Primitive Roots (欧拉函数 & 原根)
来源:互联网 发布:淘宝的保证金怎么退 编辑:程序博客网 时间:2024/05/21 11:16
题目链接:http://poj.org/problem?id=1284
题意:给定一个奇素数,求该数有多少原根
思路:φ(φ(n)) 表示n的原根的数目
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int p;int phi(int n){ int res = n,t = n; for(int i = 2; i * i <= n; i ++){ if(t % i == 0){ res = res / i * (i - 1); while(t % i == 0) t /= i; } } if(t > 1) res = res / t * (t-1); return res;}int main(){ while(~scanf("%d",&p)){ printf("%d\n",phi(p-1)); } return 0;}
阅读全文
0 0
- poj1284 Primitive Roots(原根,欧拉函数)
- POJ1284 Primitive Roots (欧拉函数 & 原根)
- Primitive Roots(Poj1284)(欧拉函数+原根)
- poj1284 Primitive Roots:欧拉函数+原根
- POJ1284:Primitive Roots(欧拉函数的应用,奇素数的原根)
- poj1284 Primitive Roots (欧拉函数)
- POJ1284 Primitive Roots(原根定理)
- poj1284——Primitive Roots(欧拉函数)
- poj1284 Primitive Roots 【原根】
- POJ1284 Primitive Roots【原根】
- Primitive Roots +欧拉函数+原根
- POJ 1284 Primitive Roots (原根,欧拉函数)
- POJ 1284 Primitive Roots 原根(欧拉函数)
- poj 1284 Primitive Roots(原根+欧拉函数)
- POJ1284---Primitive Roots(求原根个数, 欧拉函数)
- poj1284 Primitive Roots 原根个数
- poj1284(欧拉函数、原根)
- POJ 1284 Primitive Roots (欧拉函数&原根定理)
- spring boot注解
- 使用cmd命令创建thinkphp5中的资源控制器
- 汉诺塔用递归算法
- win10下安装TensorFlow1.4.0-GPU
- 67 个拯救前端开发者的工具、库和资源
- POJ1284 Primitive Roots (欧拉函数 & 原根)
- 数据库连接池参数说明--基于tomcat
- 图片通道转换
- MySQL必知必会
- Django URL传递参数的方法总结
- 一些常用的java算法练习
- Nginx日志配置及分割
- 第一阶段-入门详细图文讲解tensorflow1.4 -安装(二)Windows CPU or GPU
- java的4种安全沙箱之ClassLoader双亲委派机制