poj 1284 Primitive Roots(未完)
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 3155 | Accepted: 1817 |
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
#include<iostream>
using namespace std;
int euler(int a){
int i=;
int ans=a;
if(a%==){
//cout<<2<<endl;
ans=ans/i*(i-);
while(a%==){
a/=;
}
}
for(i=;i<=a;i+=){//优化
if(a%i==){
//cout<<i<<endl;
ans=ans/i*(i-);
while(a%i==){
a/=i;
}
}
}
return ans;
}
int main()//23, 28, and 33
{
int p;
while(cin>>p){
cout<<euler(p-)<<endl;
}
return ;
}
poj 1284 Primitive Roots(未完)的更多相关文章
- POJ 1284 Primitive Roots 原根
题目来源:POJ 1284 Primitive Roots 题意:求奇素数的原根数 思路:一个数n是奇素数才有原根 原根数是n-1的欧拉函数 #include <cstdio> const ...
- poj 1284 Primitive Roots (原根)
Primitive Roots http://poj.org/problem?id=1284 Time Limit: 1000MS Memory Limit: 10000K Descr ...
- 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: 2479 Accepted: 1385 D ...
- 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
从来没有接触过完全剩余系,不会证明,知道看了别人的题解才知道要用欧拉函数: 下面是证明过程: p是奇素数,如果{xi%p | 1 <= i <= p - 1} = {1,2,...,p-1 ...
- (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
http://poj.org/problem?id=1284 题意:求一个素数p的原根个数.(p<=65535) #include <cstdio> #include <cst ...
随机推荐
- Android自定义组件之自动换行及宽度自适应View:WordWrapView
目的: 自定义一个ViewGroup,里面的子view都是TextView,每个子view TextView的宽度随内容自适应且每行的子View的个数自适应,并可以自动换行 一:效果图 二:代码 整 ...
- java web 中分布式 session 的实现
已经有现成的库现实现分布式的 session 管理: 1.memcached-session-manager. 2.tomcat-redis-session-manager. 3.spring-ses ...
- Linux的用户及权限相关
sudo:用户想要使用sudo提升权限运行命令的话,需要把他加到sudo的list中 否则会报错:xxx is not in the sudoers file. 步骤 切换到root用户,运行visu ...
- C# 获取唯一数字
/// <summary> /// 如果你想生成一个数字序列而不是字符串,你将会获得一个19位长的序列.下面的方法会把GUID转换为Int64的数字序列. /// </summary ...
- C# 读Autofac源码笔记(2)
刚看了下Autofac属性注入的源码 首先看看WithProperty方法 image.png Autofac将我们的属性值,存在了一个list集合中 image.png 然后将这个集合传递到 ...
- python - 实现文本分类[简单使用第三方库完成]
第三方库 pandas sklearn 数据集 来自于达观杯 训练:train.txt 测试:test.txt 概述 TF-IDF 模型提取特征值建立逻辑回归模型 代码 # _*_ coding:ut ...
- OCP 052题库全变,最新052考试题及答案整理-第11题
11.Which three are true about UNDO data? A) It is used to roll back failed transactions. B) It is us ...
- KVM 安装 VMware 虚拟机
去掉了“双引号”改为:vmx.allowNested = TRUE 打开在其中创建虚拟机的文件夹VMDISK和搜索与您的虚拟机的名称. vmx 文件. 用记事本打开它,并添加上述条目. 所以 vmx. ...
- 各种 Python 库/模块/工具
1 算法 1.1 字符串处理 re 正则表达式的标准库. StringIO / cStringIO 以读写文件的方式来操作字符串(有点类似于内存文件). cStringIO 是 C 语言实现的,提供高 ...
- uC/OS-II 函数之OSInit()
获得更多资料欢迎进入我的网站或者 csdn或者博客园 对于有热心的小伙伴在微博上私信我,说我的uC/OS-II 一些函数简介篇幅有些过于长应该分开介绍.应小伙伴的要求,特此将文章分开进行讲解.本文主要 ...