【POJ1284】Primitive Roots】的更多相关文章

[题目大意] 给你一个素数n,求n的原根个数. [题解] 关于原根有一个定理: 定理:如果模有原根,那么它一共有个原根. 所以这题就是求phi[phi[n]] 很简单吧...(如果知道这个定理的话) /************** POJ 1284 by chty 2016.11.10 **************/ #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring>…
题目描述: 题意: 定义原根:对于一个整数x,0<x<p,是一个mod p下的原根,当且仅当集合{ (xi mod p) | 1 <= i <= p-1 } 等于{ 1, ..., p-1 }.给定p,询问有多少个满足定义的原根. 这里有一个定理:如果p有原根,则它恰有φ(φ(p))个不同的原根 证明不懂就算了,我也不懂啊TAT 证明如下 题目中说m是奇素数,所以φ(p)=p-1,故ans=φ(p-1). 代码如下: #include<cstdio> #include&…
Primitive Roots   Description We say that integer x, 0 < x < n, is a primitive root modulo n if and only if the minimum positive integer y which makes x y = 1 (mod n) true is φ(n) .Here φ(n) is an arithmetic function that counts the totatives of n,…
题意:求奇质数 P 的原根个数.若 x 是 P 的原根,那么 x^k (k=1~p-1) 模 P 为1~p-1,且互不相同. (3≤ P<65536) 解法:有费马小定理:若 p 是质数,x^(p-1)=1 (mod p).这和求原根有一定联系. 再顺便提一下欧拉定理:若 a,n 互质,那么 a^Φ(n)=1(mod n).    还有一个推论:若x = y(mod φ(n) 且 a与n 互质,则有 a^x=a^y(mod n). 百度百科是这么说的:"原根,归根到底就是 x^(p-1)=…
http://poj.org/problem?id=1284 给一个奇质数p,求p的原根数量. 有一个结论:当正整数n存在原根时,其一共有phi(phi(n))个不同余的原根. 所以答案为phi(p-1). #include<algorithm> #include<iostream> #include<cstring> #include<cctype> #include<cstdio> #include<cmath> #include…
一.题目 We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (x i mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive powers of 3 modulo 7 are 3, 2, 6, 4, 5, 1, and thus…
Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4775   Accepted: 2827 Description We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 } is eq…
题目传送门 Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5434   Accepted: 3072 Description We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 }…
Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3928   Accepted: 2342 Description We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 } is eq…
题面 It is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last time. You are given two pol…