POJ 1284 Primitive Roots 数论原根。
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 2479 | Accepted: 1385 |
Description
Write a program which given any odd prime 3 <= p < 65536 outputs the number of primitive roots modulo p.
Input
Output
Sample Input
23
31
79
Sample Output
10
8
24
Source
/*
定理1:如果p有原根,则它恰有φ(φ(p))个不同的原根(无论p是否为素数都适用)
p为素数,当然φ(p)=p-1,因此就有φ(p-1)个原根 数学差的人,很伤不起...
*/ #include<stdio.h> int Euler(int n)
{
int i,temp=n;
for(i=;i*i<=n;i++)
{
if(n%i==)
{
while(n%i==)
n=n/i;
temp=temp/i*(i-);
}
}
if(n!=)
temp=temp/n*(n-);
return temp;
} int main()
{
int n;
while(scanf("%d",&n)>)
{
printf("%d\n",Euler(n-));
}
return ;
}
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(原根+欧拉函数)
http://poj.org/problem?id=1284 fr=aladdin">原根 题意:对于奇素数p,假设存在一个x(1<x<p),(x^i)%p两两不同(0&l ...
- POJ 1284 Primitive Roots 原根
题目来源:POJ 1284 Primitive Roots 题意:求奇素数的原根数 思路:一个数n是奇素数才有原根 原根数是n-1的欧拉函数 #include <cstdio> const ...
- 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: 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 求原根的数量
Primitive Roots Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3381 Accepted: 1980 D ...
随机推荐
- UUID,加密解密算法的使用
注意的地方: Base64Encoder,Base64Decoder并不属于JDK标准库范畴,但是又包含在了JDK中 解决方法:按照如下方法设置Eclipse导入%JAVA_HOME%\jre\lib ...
- SAX,功能强大的 API
https://www.ibm.com/developerworks/cn/xml/x-saxapi/ SAX,功能强大的 API 在摘自 XML by Example 的本篇预览中比较了 DOM 和 ...
- Python初体验(一)—【配置环境变量】【变量】【input】【条件语句】【循环语句】
写在前面的: 作为一个控制专业的女研究生,不知道每天在研究什么,但总归逃脱不了码代码的命运.之前也学习过一些C语言.C++,基础嘛,稍稍微有一些.本不想走上码农的道路,天真烂漫的过此生(白日梦过程中. ...
- YYYY-mm-dd HH:MM:SS 时间格式
YYYY-mm-dd HH:MM:SS部分解释 d 月中的某一天.一位数的日期没有前导零. dd 月中的某一天.一位数的日期有一个前导零. ...
- 自动安装zabbix_agent脚本 -- python2
#!/usr/bin/env python # -*- coding: utf-8 -*- import os ZABBIX_SERVER_IP='10.171.100.28' if os.path. ...
- 【树】Binary Tree Right Side View
题目: Given a binary tree, imagine yourself standing on the right side of it, return the values of the ...
- Chapter 3 Phenomenon——12
Naturally, the ambulance got a police escort to the county hospital. 自然而然的,救护车让一个警察陪护到县医院去. 自然,救护车一路 ...
- android studio 3.1.4下载安装配置(附旧版本下载地址)
windows下安装android studio.当前时间2018年9月. 最新版本的android studio3.2.0-release出来了,拥有许多新的特性 可能我是一个业余的android开 ...
- centos6.5 + 7 静态ip配置
2017/09/19日更, centos6.5 可用 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static D ...
- Nodejs学习笔记(九)—与Redis的交互(mranney/node_redis)入门
简介和安装 redis简介: 开源高性能key-value存储:采用内存中(in-memory)数据集的方式,也可以采用磁盘存储方式(前者性能高,但数据可能丢失,后者正好相反) 支持字符串(strin ...