Link:

Codeforces #174 传送门

 

A:

求原根的个数,有一条性质是原根个数为$\phi(\phi(n))$,多了一个不会证的性质

如果要确定哪些是原根的话还是要枚举,不过对于每个数不用枚举$p$次了

由于$\delta_p(x) | \phi(x)$,只要对欧拉函数值的约数枚举即可

不过此题好像直接$O(p^2)$枚举就行了……

#include <bits/stdc++.h>

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> P;
typedef double db;
int p,res;

int main()
{
    scanf("%d",&p);
    for(int i=1;i<p;i++)
    {
        bool f=1;int t=1;
        for(int j=1;j<=p-2;j++)
        {
            t=(t*i)%p;
            if(t==1) f=0;
        }
        if(t*i%p!=1) f=0;
        res+=f;
    }
    printf("%d",res);
    return 0;
}
Problem A

相关文章: