poj 1284欧拉函数求素数元根个数

欧拉函数的证明以及应用(附POJ例题) 定义ϕ(x):1到x中与x互质的数的个数。\phi(x):1到x中与x互质的数的个数。 欧拉函数公式:若x可以被分解素数分解为x=ap11ap22...apkkx=a_1^{p_1}a_2^{p_2}...a_k^{p_k}则ϕ(x)=x(1−1a1)(1−1a2)...(1−1ak)\phi(x)=x(1-{1\over a_1})(1-{1\over a_2})...(1-{1\over a 阅读详情
Primitive Roots
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 3601 Accepted: 2101

Description

We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive powers of 3 modulo 7 are 3, 2, 6, 4, 5, 1, and thus 3 is a primitive root modulo 7. 
Write a program which given any odd prime 3 <= p < 65536 outputs the number of primitive roots modulo p. 

Input

Each line of the input contains an odd prime numbers p. Input is terminated by the end-of-file seperator.

Output

For each p, print a single number that gives the number of primitive roots in a single line.

Sample Input

23
31
79

Sample Output

10
8
24


这题是欧拉函数的简单应用。

phi(p-1)即为素数p的元根个数。

简单的推导:

对于给出的素数p,
首先要明确一点:p的元根必然是存在的(这一点已由Euler证明,此处不再赘述),因此,不妨设其中的一个元根是a0(1<=a0<=p-1)
按照题目的定义,a0^i(1<=i<=p-1) mod p的值是各不相同的,再由p是素数,联系Fermat小定理可知:q^(p-1) mod p=1;(1<=q<=p-1)(这个在下面有用)
下面证明,如果b是p的一个异于a的元根,不妨令b与a0^t关于p同余,那么必然有gcd(t,p-1)=1,亦即t与p-1互质;反之亦然;
证明:
若d=gcd(t,p-1)>1,令t=k1*d,p-1=k2*d,则由Fermat可知
(a0^(k1*d))^k2 mod p=(a0^(k2*d))^(k1) mod p=(a0^(p-1))^(k1) mod p=1
再由b=a0^t (mod p),结合上面的式子可知:
(a0^(k1*d))^k2 mod n=b^k2 mod p=1;
然而b^0 mod p=1,所以b^0=b^k2 (mod p),所以b^i mod p的循环节=k2<p-1,因此这样的b不是元根;
 
再证,若d=gcd(t,p-1)=1,即t与p-1互质,那么b必然是元根;
否则假设存在1<=j<i<=p-1,使得b^j=b^i (mod p),即a0^(j*t)=a0^(i*t) (mod p),由a0是元根,即a0的循环节长度是(p-1)可知,(p-1) | (i*t-j*t)->(p-1) | t*(i-j),由于p与
t互质,所以(p-1) | (i-j),但是根据假设,0<i-j<p-1,得出矛盾,结论得证;

由上面的两个证明可知b=a0^t (mod p),是一个元根的充要条件是t与p-1互质,所有的这些t的总个数就是Phi(p-1);

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <functional>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

long long phi(long long n)
{   
	long long  i,cnt,j;
	cnt=n;
	for(i=2;i*i<=n;i++)
	{
	  if(n%i==0)
	  {
	  	cnt=cnt-cnt/i;
	  	while(n%i==0)n=n/i;
	  }
	}
	if(n>1)cnt=cnt-cnt/n;
    return cnt;
	
}

int main(int argc, char const *argv[])
{
	long long i,j,k,m,n;
	while(~scanf("%lld",&n))
	{
		if(n==0)break;
		printf("%lld\n",phi(n-1));
	}
	return 0;
}



ENS160传感器原理图设计,已量产(空气质量传感器) ENS160 是一款集成式数字空气质量传感器,核心优势源于 “MEMS 传感元件 + 内置微处理器” 的架构。 阅读详情

相关推荐

Visual studio 2013 配置 Halcon 13 (非抄袭)

Visual studio 2013 配置 Halcon 13.0.2.2 (其他版本适用) 针对网上抄袭的配置方法均不可用,写了一篇亲试可行的配制方法。如下: 1.下载Halcon安装后(C:\Program Files\MVTec\HALCON-13.0) 添加环境变量,(按下win按键,键入“环境变量”,出现 “编辑系统环境变量”后按下enter即可打开,下方找到“环境变量”按钮)的系...

huyanjackson的专栏 1046

数论之原根

简介: 原根是数论中一个非常重要的概念,它在密码学中有着很广泛的应用。原根从直观上非常好理解,数g对与p是原根,则(g^i)%p的结果互不相同,其中,i ∈ [1, p-1], g ∈ [2, p-1]。原根与整数的阶的关系非常密切,下面先从整数的阶讲起。

fuyukai的专栏 8717

ICC 实战解析——CTS 时钟树综合中的关键设置与优化策略

本文深入解析ICC工具中CTS时钟树综合的关键设置与优化策略,涵盖时钟树异常引脚设置、目标参数配置、非默认布线规则(NDR)等核心技术。通过实战案例展示如何有效控制时钟偏差、优化信号完整性,并平衡功耗与面积,为芯片物理设计提供专业指导。

weixin_30872577的博客 329

原根

定理:如果p为素数,那么素数p一定存在原根,并且p的原根的个数为phi(p-1). 设m是正整数,a是整数,若a模m的阶等于φ(m),则称a为模m的一个原根. 假设一个数g对于P来说是原根,那么g^i mod P的结果两两不同,且有 1那么g可以称为是P的一个原根,归根到底就是g^(P-1) = 1 (mod P)当且 仅当指数为P-1的时候成立.(这里P是素数). 求原根目前的做法只

ACdreamer 1万+

安时积分法和开路电压法结合估算锂电池SOC

基于安时积分法和开路电压法结合的锂电池SOC估计Simulink仿真建模,利用安时积分法计算放电过程中的SOC,在搁置状态利用开路电压法进行SOC修正。

qq_39304296的博客 2568

SQL 通过sum() over(order by ,rownum)实现财务现金日记账实例

SELECT 类型,to_char(发生日期,'yyyy-MM-dd') 发生日期,期初余额,借方金额,贷方金额, (CASE WHEN 借方金额>0 THEN '借' WHEN 贷方金额>0 THEN '贷' ELSE '平' END) 方向, sum(收支金额) over(order by 发生日期, rownum) 余额 FROM( SELECT LX 类型,账户,账号,摘要,发生日期,单据ID, ...

qq_41451794的博客 1026

POJ 1284 Primitive Roots(素数原根)

设m是正整数,a是整数,若a模m的阶等于φ(m),则称a为模m的一个原根。(其中φ(m)表示m的欧拉函数) 本题需应用的结论:若p是一个素数,则p有φ(p-1)个原根。 #include using namespace std; const int maxn =10000+5; int ph(int x) { int ans=x; for(int i=2;i*i<=x;i++

Learn as if you were to live forever 711

手把手教你学基带SOC芯片(4.4.9)--基带芯片的电源管理实例:高通 Snapdragon 系列实例(十)

Snapdragon 888 通过支持多种深度睡眠模式,如 AOAC 模式、低功耗模式和深度睡眠模式,以及智能电源管理技术,实现了对功耗的精细管理。这些模式不仅延长了设备的电池寿命,还确保了用户在各种使用场景下的良好体验。无论是保持网络连接、限制后台活动,还是完全关闭不必要的功能,Snapdragon 888 都能够灵活应对,提供高效的功耗管理方案。

MHD0815的博客 745

原根(1)

简介: 原根是数论中一个非常重要的概念,它在密码学中有着很广泛的应用。原根从直观上非常好理解,数ggg对与ppp是原根,则gi(mod&nbsp;p)gi(mod&nbsp;p)g^i(mod\space p)的结果互不相同,其中,i∈[1,p−1],g∈[2,p−1]i∈[1,p−1],g∈[2,p−1]i ∈ [1, p-1], g ∈ [2, p-1]。原根与整数的阶的关系非常密切,下面先...

Hellsegamosken 1522

ZYNQ GP总线实现PS与PL交互

3,完成 ZYNQ7 Processing System 的配置更改后,回到 Diagram 界面中,可以看到新出现了名为 M_AXI_GP0_ACLK、M_AXI_GP0 和 FCLK_CLK0 的接口,下面我们要对这些接口进行连接或引出。此处的偏移量,AXI的相邻寄存器偏移量相差4个字节,默认slv_reg0的偏移量是0,可以推导出slv_reg1,slv_reg2的偏移量分别为4和8,这里只用到了slv_reg0,所以偏移量为0。当然了,窗口数量的增加,势必会使得单个窗口的采样深度变小。

wangjie36的博客 7098

Python从0到100完整学习指南(必看导航)

想做这件事情很久了,这次我更新了自己所写过的所有博客,汇集成了Python从0到100,共一百节课,帮助大家一个月时间里从零基础到学习Python基础语法、Python爬虫、Web开发、 计算机视觉、机器学习、神经网络以及人工智能相关知识,成为学业升学和工作就业的先行者!

拥有百余位万粉技术博主、200余位可合作代发博主,私域技术社群规模达千人,商务合作私信 6万+

【数论】【素数】素数相关基础——欧拉函数与欧拉定理

1、 欧拉函数   欧拉函数 φ(n)表示不超过n且与n互素的正整数的个数 。 φ(n)=n*(1-1/p1)*(1-1/p2)*…其中p1,p2…为n的质因数 2、欧拉定理 若a,n是正整数,且a,n互质,则有a^ φ(n) mod n =1。实际上这是费马小定理的一个推广。 3、欧拉函数打表 在实际运用中,用朴素方法去一次次求欧拉函数的值是很慢的,所以我们可以采用打表的方法来提高效率

Lorry酱的专栏 3021

SAP Joule 经过了超过 2.5 亿行 ABAP 代码的训练之后......

披露的统计数据,Joule 提供的这种全新系统交互方式,可将事务性任务执行速度提高 90%,访问 SAP Help Portal 内容的速度提高 95%。在 ABAP 应用开发领域,SAP 官网数据显示,Joule 经过超过 2.5 亿行 ABAP 代码的训练,有信心成为这一领域行业领先的代码助手。刚刚过去的 SAP 蓝宝石大会上,SAP 提到,从2023年第四季度以来,SAP 已经交付了 50 项基于人工智能的创新。让其生成 SAP 应用能够识别的结构化应用数据,业务用户全程无需离开 SAP 应用程序。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 816

poj1284(欧拉函数+原根)

题目链接:https://vjudge.net/problem/POJ-1284 题意:给定奇素数p,求x的个数,x为满足{(xi mod p)|1<=i<=p-1}={1,2,...,p-1}。 思路:题目的实质就是问p有多少原根。   下面是百度对原根的解释:    设m是正整数,a是整数,若a模m的阶等于φ(m),则称a为模m的一个原根。(其中φ(m)表示m的欧拉函数)  ...

weixin_34227447的博客 236

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

POJ 1284-Primitive Roots(欧拉函数求原根个数)

Primitive Roots Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1284 Appoint description:  System Crawler  (2015-04-06) Descripti

Rocky0429 1873

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

poj1284 - 原根+欧拉函数

Primitive Roots Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6012 Accepted: 3434 Description We say that integer x, 0 < x < p, is a primitive root modulo odd ...

m0_37579232的博客 287

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

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

【poj1284-Primitive Roots】欧拉函数-奇素数的原根个数 http://poj.org/problem?id=1284 题意:给定一个奇素数p,求p的原根个数。 原根:{ (ximod p) | 1 &lt;= i &lt;= p-1 } is equal to { 1, ..., p-1 },则x是p的原根。 ...

qq_25768269的博客 453

poj1284 Primitive Roots 原根个数

Description We say that integer x, 0 i mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive powers of 3 modulo 7 are 3, 2, 6, 4, 5, 1, and thus 3 is a primitive root m

878

POJ 1284 Primitive Roots (求原根个数)

Primitive Roots 题目链接:http://poj.org/problem?id=1284 利用定理:素数 P 的原根的个数为euler(p - 1) typedef long long ll; using namespace std; /* 求原根 g^d ≡ 1(mod p) 当中d最小为p-1。g 便是一个原根 复杂...

aoe41606的博客 110

poj1284 Primitive Roots(原根,欧拉函数)

http://poj.org/problem?id=1284 题意:求一个奇素数的原根个数。 思路:原根定义:here。 感觉和费马小定理有点像,定义里都说“归根到底就是g^(P-1) = 1 (mod P)当且仅当指数为P-1的时候成立.(这里P是素数).”。 说白了就是用了一个定理: 一个数n有原根,那么他有phi(phi(n))个模n不同余的原根(n是否素数都可用)。

Iguodala的博客 714

POJ1284 Primitive Roots - 数论 - 原根 - 欧拉函数

Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6187   Accepted: 3529 Description We say that integer x, 0 < x < p, is a primitive root modulo odd prime p...

太阳升起 402

欧拉函数 素数原根 POJ 1284

这道题用到一个定理:一个奇素数p的原根个数phi(p-1),然后就求p-1的欧拉函数就好了。 代码: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #inc

hexiecs的技术专栏 618

poj 1284 Primitive Roots(求原根的个数)

Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2590   Accepted: 1459 Description We say that integer x, 0 i mod p) | 1 <= i <= p-1 } is equal

WEYuLi的专栏 1185

Primitive Roots POJ - 1284(欧拉函数和原根)

Primitive Roots POJ - 1284 题目链接:https://vjudge.net/problem/POJ-1284#author=laguna 题目: 孤单的zydsg又一次孤单的度过了520,不过下一次不会再这样了。zydsg要做些改变,他想去和同余小姐姐约会。 已知zydsg的号码为一个奇素数p,所有同余小姐姐的编号x都满足 0 < x &l...

weixin_30633949的博客 199

poj1284Primitive Roots【欧拉函数 原根】

Language: Default Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3680   Accepted: 2153 Description We say that integer x, 0 i mod p) | 1

走一步再走一步 702

poj 1284 求原根的个数(欧拉函数的应用)

用到一个结论:如果p是素数,则p有φ(p-1)个原根。然后就是直接求φ函数的值了 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <stack> 5 #include <queue> 6 #incl...

a704786571的博客 190
上一篇: poj2407欧拉函数模板
下一篇: poj2773 欧拉函数+整除性质
ctrss
博客等级 码龄11年 1粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值