题目链接:

https://cn.vjudge.net/problem/POJ-1284

题目大意:

就是给出一个奇素数,求出他的原根的个数。

解题思路:

由于是m是奇素数,m的欧拉函数值为m - 1,所以直接求出ϕ(m - 1)即可

 #include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
int euler_phi(int n)//求单个
{
int m = (int)sqrt(n + 0.5);
int ans = n;
for(int i = ; i <= m; i++)if(n % i == )
{
ans = ans / i * (i - );
while(n % i == )n /= i;
}
if(n > )ans = ans / n * (n - );
return ans;
}
int main()
{
int n;
while(cin >> n)
{
cout<<euler_phi(n - )<<endl;
}
return ;
}

POJ-1284 Primitive Roots---原根&欧拉函数的更多相关文章

  1. POJ 1284 Primitive Roots 原根

    题目来源:POJ 1284 Primitive Roots 题意:求奇素数的原根数 思路:一个数n是奇素数才有原根 原根数是n-1的欧拉函数 #include <cstdio> const ...

  2. (Relax 数论1.8)POJ 1284 Primitive Roots(欧拉函数的应用: 以n为模的本原根的个数phi(n-1))

    /* * POJ_2407.cpp * * Created on: 2013年11月19日 * Author: Administrator */ #include <iostream> # ...

  3. POJ 2478 Farey Sequence(欧拉函数前n项和)

    A - Farey Sequence Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u ...

  4. poj 1284 Primitive Roots

    从来没有接触过完全剩余系,不会证明,知道看了别人的题解才知道要用欧拉函数: 下面是证明过程: p是奇素数,如果{xi%p | 1 <= i <= p - 1} = {1,2,...,p-1 ...

  5. poj 2480 Longge's problem [ 欧拉函数 ]

    传送门 Longge's problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7327   Accepted: 2 ...

  6. poj 3090 &amp;&amp; poj 2478(法雷级数,欧拉函数)

    http://poj.org/problem?id=3090 法雷级数 法雷级数的递推公式非常easy:f[1] = 2; f[i] = f[i-1]+phi[i]. 该题是法雷级数的变形吧,答案是2 ...

  7. POJ 2407:Relatives(欧拉函数模板)

    Relatives AC代码 Relatives Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16186   Accept ...

  8. POJ 2478 线性递推欧拉函数

    题意: 求sigma phi(n) 思路: 线性递推欧拉函数 (维护前缀和) //By SiriusRen #include <cstdio> using namespace std; # ...

  9. poj 1284 Primitive Roots(原根+欧拉函数)

    http://poj.org/problem?id=1284 fr=aladdin">原根 题意:对于奇素数p,假设存在一个x(1<x<p),(x^i)%p两两不同(0&l ...

  10. 【poj1284-Primitive Roots】欧拉函数-奇素数的原根个数

    http://poj.org/problem?id=1284 题意:给定一个奇素数p,求p的原根个数. 原根: { (xi mod p) | 1 <= i <= p-1 } is equa ...

随机推荐

  1. Windows加密API的层次

    Windows平台下的应用程序可以分为托管的.NET程序和本机的Win32(以及Win64)两大类..NET有着类似于JAVA的虚拟机和二进制码托管运行环境,提供了在不同Windows平台上的代码可携 ...

  2. [转载+原创]Emgu CV on C# (五) —— Emgu CV on 局部自适应阈值二值化

    局部自适应阈值二值化 相对全局阈值二值化,自然就有局部自适应阈值二值化,本文利用Emgu CV实现局部自适应阈值二值化算法,并通过调节block大小,实现图像的边缘检测. 一.理论概述(转载自< ...

  3. pom resource配置

    maven pom配置资源resource, make时可自动发布到release目录的 \WEB-INF\classes 下. 解决使用idea时, 每次都需要配置资源文件的手动配置. 具体: &l ...

  4. isnull函数

    isnull是判断一个字段是否为空值,返回一个特定的值 列: isnull(a,0)  如果a字段有空值返回0 没有空值就返回a的本身 isnull(a,1)=2 字段a有空值返回1,判断isnull ...

  5. 如何通过 PHP 获取 Azure Active Directory 令牌

    在调用 Azure Rest API 时,如果是属于 Azure Resource Manager 的 API,则需要使用 Azure Active Directory (Azure AD)认证获取令 ...

  6. spring mvc随笔

    一.SpringMvc学习笔记1.使用SpringMvc时需在web.xml文件中添加配置 <servlet> <servlet-name>springMVC</serv ...

  7. SZU1

    CodeForces 518A 字符串进位.. #include <iostream> #include <string> #include <cstring> # ...

  8. java 错误: 未报告的异常错误Exception; 必须对其进行捕获或声明以便抛出

    import java.io.FileInputStream; import java.util.Properties; import java.sql.Connection; import java ...

  9. oracle中,改变表名和字段名的大小写

    1.将表名和字段名改为大写  见--http://www.cnblogs.com/wenboge/articles/4121331.html 2.将表名和字段名改为小写 ①改表名为小写 begin f ...

  10. Create a soft keyboard

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...