POJ 1284 原根(欧拉函数)

DIC新手避坑指南:压缩实验中的应变测量常见错误与数据校验技巧 本文为DIC技术新手提供了压缩实验中应变测量的全面避坑指南。文章系统梳理了从试样尺寸录入、散斑质量到数据后处理中应变方向与符号混淆、数据插值对齐等常见错误,并分享了基于MATLAB的自动化数据校验与可视化对比技巧,帮助建立可靠的实验数据分析SOP,确保DIC测量结果的准确性。 阅读详情

时空隧道


题目大意:
给出奇素数n,求出n的原根的个数


分析:
暑假没好好听课QAQ…不得不去百度了一发原根是什么…
假设n的原根为x,那么x满足以下性质:
x^1modn与x^2modn与……x^phi(n)modn的ans互不相同


对于此题,题目中规定n是一个奇素数,所以n一定是有原根的(证明自行百度吧233)
接下来介绍一个定理:
n的原根个数=phi(phi(n))
因为n是奇素数所以phi(n)=n-1
所以ans=phi(n-1)


代码如下:

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
//by NeighThorn
using namespace std;
const int maxn=65536+5;
int n,phi[maxn],prime[maxn],vis[maxn],cnt;
signed main(void){
    memset(vis,0,sizeof(vis)),cnt=0;
    for(int i=2;i<=65536;i++){
        if(!vis[i])
            prime[++cnt]=i,phi[i]=i-1;
            for(int j=1;j<=cnt&&prime[j]*i<=65536;j++){
                vis[prime[j]*i]=1;
                if(i%prime[j]==0){
                    phi[i*prime[j]]=prime[j]*phi[i];
                    break;
                }
                else
                    phi[i*prime[j]]=(prime[j]-1)*phi[i];
            }
    }
    while(scanf("%d",&n)!=EOF)
        cout<<phi[n-1]<<endl;
    return 0;
}

by >_< NeighThorn

第110章 PCL PointCloudFusing 点云融合重建详细讲解 点云融合是指将多个不同视角、不同位置、不同传感器获取的点云数据进行合并,得到一个更加完整、准确的三维模型。多视角扫描:从多个相机或传感器获取点云数据,需要将这些数据融合成一个统一的三维模型。传感器融合:例如将激光雷达(LiDAR)点云与相机的图像数据融合,以便获得更高质量的三维重建。动态场景重建:动态环境中的物体,点云数据不断更新,如何平滑地融合这些点云是一个重要课题。点云融合的目标是将不同来源的点云数据准确地合并,消除冗余,减少噪声,并提高整体的点云密度和精度。 阅读详情

相关推荐

PyQtWebEngine安装避坑指南:快速解决ModuleNotFoundError

本文详细解析了PyQt5开发中常见的ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'错误。核心原因是PyQt5 5.11版本后,网页引擎组件被独立为PyQtWebEngine包。文章对比了退回旧版本、独立安装及使用Conda等多种解决方案,并提供了针对Windows、macOS和Linux不同平台的实战安装指南与验证方法,帮助开发者快速解决依赖问题。

weixin_29056101的博客 427

POJ1284 Primitive Roots (积性函数)

原题链接:POJ1284 题意简述:定义一个概念原根(primitive root),给出p,求出p为模的原根数量。 解题思路: 原根是数论中的一个概念,有关定义和证明请看原根的性质以及如何求原根 代码实例: #include&lt;cstdio&gt; const int maxn = 1e5+10; int v[maxn],phi[maxn],primes[maxn]; int cn...

帅比王的博客 833

实战指南:从零搭建ROS2 + Cartographer 2D激光SLAM系统

本文详细介绍了如何从零开始搭建ROS2与Cartographer结合的2D激光SLAM系统,涵盖环境准备、激光雷达驱动配置、Cartographer安装与参数调优等关键步骤。通过实战案例和常见问题解决方案,帮助开发者快速掌握激光雷达建图技术,提升机器人自主导航能力。

weixin_29062255的博客 402

[欧拉函数]求原根个数

题面描述 【输入格式】 第一行n(1<=n<=10000) 下来n行,每行一个整数p,p保证为质数,表示求p的原根的数目。(1<=p<=2000 0000) 【输出格式】 每次询问输出一行一个整数,即x的原根的数目。 【样例输入】 3 23 31 79 【样例输出】 10 8 24 思路 原根个数是phi[phi[i]]个,我也不知道为什么? 代码 #include&lt...

lb2003 1536

【报错】sqli-labs靶场搭建出现“Unable to connect to the database: security”

搭建sqli-labs靶场时,“Unable to connect to the database: security”报错解决

九芒星的博客 2988

Rust嵌入式开发环境搭建指南(基于Stm32+Vscode)

本文档旨在指导开发者如何搭建基于Rust语言的STM32嵌入式开发环境。相比传统的C/C++开发方式,Rust提供了更强的内存安全保障和现代化的语言特性,非常适合嵌入式系统开发。本指南将详细介绍从环境搭建到项目配置的全过程,特别关注VSCode作为IDE的配置以及STLink和DAPLink调试器的使用。

u014627020的博客 2601

POJ1284 Primitive Roots-欧拉函数求原根个数

转自http://blog.sina.com.cn/s/blog_6a46cc3f0100tvsq.html这一题主要是用到了两个定理:1)所有的奇素数都是有原根的2)一个数n有原根,那么他有phi(phi(n))个模n不同余的原根(n是否素数都可用)3)一个素数有原根,则有phi(n-1)个原根证明:假设奇素数n的原根为r,那么r,r^1,r^2...r^phi(n)是模n不同于的,由于(r^i...

。 400

SAP 中配置权限职责菜单并分配给用户的核心流程是:用PFCG 创建 / 维护角色(含菜单、事务码、权限)→ 生成权限参数文件 → 通过 SU01/SU10 将角色分配给用户

SAP权限配置核心流程:1)通过PFCG创建角色,配置菜单事务码及权限对象;2)生成权限参数文件;3)用SU01/SU10分配角色给用户。关键步骤包括:在PFCG中维护菜单结构、设置权限字段值、生成Profile,通过用户比较验证权限。批量分配可用SU10,特殊需求可创建复合角色或自定义权限对象。常见问题需检查权限缺失(SU53)、菜单分配及组织级别设置。流程简化为:创建角色→配置权限→分配用户→验证生效。

金牌架构师 1271

poj 1284 Primitive Roots 【原根】【数论】

欧拉函数 原根

100days 2456

【DRAM存储器五十四】LPDDR5介绍--PHY简介和LPDDR5训练流程

简述LPDDR5 PHY的基本功能和训练流程简介

highman110的博客 904

2026.2.11:ollama api推理GLM-OCR模型识别图片

本文介绍了使用Ollama API调用GLM-OCR模型进行图片文字识别的过程。首先通过ollama pull glm-ocr:latest命令拉取模型,然后使用Python脚本调用API接口。代码示例展示了如何发送包含图片路径的请求,并处理返回的识别结果,支持文本、公式和表格三种识别模式。运行结果展示了模型对输入图片的识别效果,为开发者提供了便捷的OCR解决方案。

拥抱具身智能,昇腾Ascend C 363

离散对数的部分理解

离散对数中原根的部分理解 有公式: 原根的性质: 1.具有原根的数字仅有以下几种形式:2,4,pn,2⋅pn(p是奇质数) 2.一个数的最小原根的大小不超过 m14 3.若g是m的一个原根,那么gd是m的原根的充分必要条件是gcd(d,Φ(m))=1, 由此可推知一个数的原根个数为Φ(Φ(m))个 在以上公式中,例如:m=7,有欧拉函数Φ(7)=6,因为从1-6中与7互素的余数集合有{1,2,3,4,5,6},长度是6。 根据性质1,如果a可能是m的原根。d可以被Φ(7)整除,d有1,2,3,6。用

lai_me的博客 555

2024全国村级行政边界数据

五级行政区划:村边界数据产品涵盖五级行政区划:(一级行政区)省级行政区共31个其中:(台湾、香港、澳门除外);(二级行政区)地级行政区共334个其中:7个地区、3个盟、30个自治州、294个地级市;(三级行政区)县级行政区共2851个其中:1355个县、117个自治县、49个旗、3个自治旗、363个县级市、962个市辖区、1个林区、1个特区;(四级行政区)乡级行政区共40497个其中:11626个乡、1034个民族乡、20117个镇、7566个街道、151个苏木、1个民族苏木、2个县辖区公所;

J_Giser的博客 3226

欧拉函数 素数原根 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

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

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

深度学习工具包 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")

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

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

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

Primitive Roots POJ - 1284 原根, 欧拉函数

题目链接We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (x^i mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive powers of 3

wood 465

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

点击打开链接 Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2637   Accepted: 1486 Description We say that integer x, 0 i mod p) | 1 <= i

代码改变世界,keep coding。 1365

POJ 1284 Primitive Roots G++ 欧拉函数 原根 背

描述 我们说整数x,0 1 例如,3模7的连续功率是3,2,6,4,5,1,因此3是原始根模7。 写一个给定任意奇质数3 输入 输入的每一行包含一个奇素数p。 输入由文件结尾分隔符终止。 输出 对于每个p,打印一个单一的数字,在一行中给出原始根的数量。 

woniupengpeng的专栏 245

POJ1284 Primitive Roots (欧拉函数 & 原根)

题目链接:http://poj.org/problem?id=1284 题意:给定一个奇素数,求该数有多少原根 思路:φ(φ(n)) 表示n的原根的数目   #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;algorithm&gt; using namespace std; int p; int phi(in...

知与谁i的博客 261

POJ 1284 Primitive Roots (欧拉函数&原根定理)

http://poj.org/problem?id=1284 参考《数论概论》定理21.2: 完整代码: /*16ms,652KB*/ #include const int mx = 65536; int phi[mx]; void phi_table() { int i, j; for (i = 2; i < mx; ++i) if (!phi[i]

AC,∑ndless 1015

POJ1284---Primitive Roots(求原根个数, 欧拉函数)

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 power

Alex 1298

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

题意: 给你一个奇素数P, 求有多少个x 满足 x^i %P 为0~P-1. 其中1 思路: 这正是对原根的描述 假设一个数g 对于P来说是原根,那么g^i mod P 结果两两不同,且有1 这个题是求原根数量 为phi [ phi[n] ]个 欧拉函数直接打表就好了 #include #include #include using namespace std; int

aozil_yang的博客 561

POJ1284 Primitive Roots

题目链接:http://poj.org/problem?id=1284   原根,定义题面有   暴力枚举肯定会TLE   找规律,用欧拉函数,答案为phi(n-1)   附:原根的百度百科          一篇关于原根看起来很厉害的博客 鸣谢博主 ACdreamer ACdreamer

白云千载空悠悠 282
上一篇: BZOJ 2303: [Apio2011]方格染色 并查集神题
下一篇: BZOJ 1854: [Scoi2010]游戏 二分图匹配or并查集
NeighThorn
博客等级 码龄11年 20粉丝 171原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值