Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3381   Accepted: 1980 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…
题目链接 大题流程: 判定是否有原根->求出最小原根->利用最小原根找出全部原根 #include<bits/stdc++.h> using namespace std; typedef long long LL; ; ]; ]; ]; int num_prime; void init() { memset(check, false, sizeof(check)); phi[]=; ; i<=maxn; i++) { if(!check[i]) { prime[num_pri…
模板题,可用于求一个数的所有原根. #include<bits/stdc++.h> using namespace std; typedef long long ll; ,inf=0x3f3f3f3f; int n,fac[N],nf; vector<int> ans; int Pow(int x,int p,int mod) { ; ,x=(ll)x*x%mod))ret=(ll)ret*x%mod; return ret; } int phi(int x) { int ret=…
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,…
Primitive Roots http://poj.org/problem?id=1284 Time Limit: 1000MS   Memory Limit: 10000K       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 equal…
Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2479   Accepted: 1385 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…
一.题目 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…
http://poj.org/problem?id=1284 fr=aladdin">原根 题意:对于奇素数p,假设存在一个x(1<x<p),(x^i)%p两两不同(0<i<p),且解集等于{1,2....,p-1}. 称x是p的一个原根. 输入p问p的原根有多少个. 直接枚举的,TLE了. 看到discuss里面说是求原根.答案直接是phi[p-1].百度百科上直接就给出答案了.m有原根的充要条件是m= 1,2,4,p,2p,p^n,当中p是奇素数,n是随意正整数…
题目:http://poj.org/problem?id=1284 题意:就是求一个奇素数有多少个原根 分析: 使得方程a^x=1(mod m)成立的最小正整数x是φ(m),则称a是m的一个原根 然后有这样的定理: 1.所有奇素数都有原根 2.如果一个数n有原根,那么原根个数为φ(φ(n)) 由性质2就可知道,对于此题的奇素数n,结果就是φ(n-1)…
Primitive Roots 题目链接:id=1284">http://poj.org/problem?id=1284 利用定理:素数 P 的原根的个数为euler(p - 1) typedef long long ll; using namespace std; /* 求原根 g^d ≡ 1(mod p) 当中d最小为p-1.g 便是一个原根 复杂度:O(m)*log(P-1)(m为p-1的质因子个数) */ ll euler(ll x) { ll res = x; for (ll i…