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 ...
随机推荐
- jzoj5710
對於每個詢問,我們先考慮插入1~r中每個數的答案,這樣子就不用考慮後面數對現在的影響 那麼我們可以在權值線段樹的每一個位置存儲每一個值最後一次結束的位置 問題變成了,如何判斷區間連續? 我們可以對線段 ...
- win32 音视频相关 api
waveInGetNumDevs waveInGetDevCaps waveInOpen waveInGetDevCaps waveInPrepareHeader waveInAddBuffer wa ...
- 表格(table)
<table border="1"; align="center" cellspacing="0"> <tr> &l ...
- 在 iOS 上编译 webkit 源码
准备工作 买一台 mac 下载并安装 Xcode 下载源码 git clone git://git.webkit.org/WebKit.git WebKit 这个可能要耗费很久很久 编译源码 打开 X ...
- Hbuilder用ajax连接eclipse中的servlet例子以及注意事项
今天用前端神器Hbuilder连接eclipse中的servlet,真是费了九牛二虎之力,才把问题解决 Hbuilder中的代码: test.html <!DOCTYPE html> &l ...
- XP系统安装VS2010失败的解决方法
今天装了一个双系统,但是在XP系统上安装VS2010的时候就出现了下面的错误 于是在网上搜索各种资源,查看错误日志,网上说是office2007的原因,我也抱着试试看的态度去卸载了,可是卸载后却发现还 ...
- 使用R进行分组统计
分组统计数据集是很常见的需求,R中也有相应的包支持数据集的分组统计.自己尝试了写了段R代码来完成分组统计数据集,支持公式,感觉用起来还算方便.代码分享在文章最后. 使用方式: step 1: sour ...
- (转)Python——functools
原文:https://www.cnblogs.com/Security-Darren/p/4168310.html#t7 http://www.wklken.me/posts/2013/08/18/p ...
- 2018春招-今日头条笔试题-第四题(python)
题目描述:2018春招-今日头条笔试题5题(后附大佬答案-c++版) #-*- coding:utf-8 -*- class Magic: ''' a:用于存储数组a b:用于存储数组b num:用于 ...
- hibernate的配置文件,使用XML方式
<?xml version="1.0" encoding="UTF-8"?> <!-- 标准的XML文件的起始行,version='1.0'表 ...