POJ 1284 Primitive Roots 原根
题意:求奇素数的原根数
思路:一个数n是奇素数才有原根 原根数是n-1的欧拉函数
- #include <cstdio>
- const int maxn = 70000;
- int phi[maxn];
- void phi_table(int n)
- {
- for(int i = 2; i <= n; i++)
- phi[i] = 0;
- phi[1] = 1;
- for(int i = 2; i <= n; i++)
- if(!phi[i])
- for(int j = i; j <= n; j += i)
- {
- if(!phi[j])
- phi[j] = j;
- phi[j] = phi[j] / i * (i-1);
- }
- }
- int main()
- {
- phi_table(65536);
- int n;
- while(scanf("%d", &n) != EOF)
- {
- printf("%d\n", phi[n-1]);
- }
- return 0;
- }
POJ 1284 Primitive Roots 原根的更多相关文章
- poj 1284 Primitive Roots (原根)
Primitive Roots http://poj.org/problem?id=1284 Time Limit: 1000MS Memory Limit: 10000K Descr ...
- POJ 1284 Primitive Roots (求原根个数)
Primitive Roots 题目链接:id=1284">http://poj.org/problem?id=1284 利用定理:素数 P 的原根的个数为euler(p - 1) t ...
- POJ 1284 Primitive Roots 数论原根。
Primitive Roots Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2479 Accepted: 1385 D ...
- poj 1284 Primitive Roots(原根+欧拉函数)
http://poj.org/problem?id=1284 fr=aladdin">原根 题意:对于奇素数p,假设存在一个x(1<x<p),(x^i)%p两两不同(0&l ...
- poj 1284 Primitive Roots(未完)
Primitive Roots Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3155 Accepted: 1817 D ...
- (Relax 数论1.8)POJ 1284 Primitive Roots(欧拉函数的应用: 以n为模的本原根的个数phi(n-1))
/* * POJ_2407.cpp * * Created on: 2013年11月19日 * Author: Administrator */ #include <iostream> # ...
- POJ 1284 Primitive Roots (欧拉函数+原根)
<题目链接> 题目大意: 满足{ ( $x^{i}$ mod p) | 1 <=$i$ <= p-1 } == { 1, …, p-1 }的x称为模p的原根.给出p,求原根个数 ...
- poj 1284 Primitive Roots
从来没有接触过完全剩余系,不会证明,知道看了别人的题解才知道要用欧拉函数: 下面是证明过程: p是奇素数,如果{xi%p | 1 <= i <= p - 1} = {1,2,...,p-1 ...
- 【POJ】1284 Primitive Roots
http://poj.org/problem?id=1284 题意:求一个素数p的原根个数.(p<=65535) #include <cstdio> #include <cst ...
随机推荐
- apache tomcat 集群! (转)
公司需要一个内部测试局域网, 要求可以支持3000并发访问!以前也没做过服务器这方面.临时抱佛脚,查看了N多文档,他人经验,布置好之后,又遇到了N多问题,功夫不负有心人.终于还是完成了要求!观他人的布 ...
- java内存分析总结
1.自带的jconsole工具. (1)假设是从命令行启动,使 JDK 在 PATH 上,执行 jconsole 就可以. (2)假设从 GUI shell 启动,找到 JDK 安装路径,打开 bin ...
- 基于Gsoap 的ONVIF C++ 库
https://github.com/xsmart/onvifcpplib 该库支持ProfileS 和ProfileG,目前正在开发哪些,现拥有支持Event 下面是一个client样本 int _ ...
- Teams(uva11609+组合)
I - Teams Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit cid=7795 ...
- android 内存泄漏分析技巧
java虚拟机执行一般都有一个内存界限,超过这个界限,就会报outofmemory.这个时候一般都是存在内存泄漏.解决内存泄漏问题,窃以为分为两个步骤:分析应用程序是否真的有内存泄漏,找到内存泄漏的地 ...
- Scan IP relocate/failover其它段后不能ping通过
或手动集群重启单个节点srvctl relocate scan_listener后.群集网络段ping IP,VIP.SCAN IP正常.其他段ping SCAN IP 不通.其原因是,该路由ARP表 ...
- 【Nginx】显示器port管理
监听port属于server虚拟主机,由server{}块内的listen配置项决定. 也就是说,在server{}块配置项内定义了该虚拟主机所要监听的port. 在处理配置文件http块内main级 ...
- MongoDB(两)mongoDB基本介绍
MongoDB介绍 MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库其中功能最丰富,最像关系数据库的.他支持的数据结构很的松散,是类似json的bjson格式,因此能够存储比 ...
- Android使用HttpClient方法和易错问题
HttpClient为Android开发人员提供了跟简洁的操作Http网络连接的方法,在连接过程中也有两种方式,get和post,先看一下怎样实现的 默认是get方式 //先将參数放入List,再对參 ...
- InstallShield安装包中集成第三方安装包的方案选择
原文:InstallShield安装包中集成第三方安装包的方案选择[转] 我们在制作安装包时,有些情况下会涉及第三方安装的集成,这里将讨论如何调用安装第三方包,以及需要注意的事项. 第三方安装包的 ...