hdoj 1787 GCD Again(欧拉函数)

深入解析Apollo Lattice Planner:自动驾驶轨迹规划的核心算法与实践 本文深入解析了百度Apollo自动驾驶平台中的核心轨迹规划算法——Lattice Planner。文章详细阐述了其作为车辆“即时决策者”的工作原理,通过“采样-评估”的六步流程(Frenet坐标转换、状态采样、轨迹生成、硬约束过滤、代价函数打分及决策平滑),在复杂路况下实时规划出安全、舒适、高效的行驶轨迹。该算法是自动驾驶实现智能决策与精准控制的关键技术。 阅读详情

GCD Again

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2473    Accepted Submission(s): 1017


Problem Description
Do you have spent some time to think and try to solve those unsolved problem after one ACM contest?
No? Oh, you must do this when you want to become a "Big Cattle".
Now you will find that this problem is so familiar:
The greatest common divisor GCD (a, b) of two positive integers a and b, sometimes written (a, b), is the largest divisor common to a and b. For example, (1, 2) =1, (12, 18) =6. (a, b) can be easily found by the Euclidean algorithm. Now I am considering a little more difficult problem:
Given an integer N, please count the number of the integers M (0<M<N) which satisfies (N,M)>1.
This is a simple version of problem “GCD” which you have done in a contest recently,so I name this problem “GCD Again”.If you cannot solve it still,please take a good think about your method of study.
Good Luck!
 


Input
Input contains multiple test cases. Each test case contains an integers N (1<N<100000000). A test case containing 0 terminates the input and this test case is not to be processed.
 


Output
For each integers N you should output the number of integers M in one line, and with one line of output for each line in input.
 


Sample Input
  
2 4 0
 


Sample Output
  
0 1
 


题目大意:输入一个数N,求2~N-1之间与N的最大公约数大于1的数的个数。

用欧几里得辗转相除法判断N和2~N-1之间的数的最大公约数会超时,要用欧拉函数。

#include<stdio.h>
#include<string.h>
int N;
int Euler(int n)
{
	int ret=n,i;
	for(i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ret=ret-ret/i;
			while(n%i==0)
			n=n/i;
		}
	}
	if(n>1) ret=ret-ret/n;
	return ret;
}
int main()
{
	while(scanf("%d",&N)&&N!=0)
	{
		printf("%d\n",N-1-Euler(N));
	}
	return 0;
}
			


26.Labview波形图、XY图、强度图使用精讲 1. 波形图基础概念,如何使用,1.1 波形图与波形图表1.2 XY图如何设计、如何使用?1.3 强度图原理、如何使用、使用案例;2. 图形的参数设置2.1 波形图及波形图表的外观设计2.2 XY图的前面板设计2.3 强度图属性设置。 阅读详情

相关推荐

【Unity人物动画】SALSA With RandomEyes (语音生成嘴型/人物说话) 使用

SALSA使用探索 之前做项目时想做人物说话的嘴部动作,因为我们的语音是AI合成的,语音片段很多,如果能根据语音生成嘴部动画,那将极大便利我们的工作。后面是找到了SALSA的这款插件,并摸索出使用方法。 1 插件介绍 官方网站:https://crazyminnowstudio.com/ 一个能做2D纸片人和3D人物模型嘴部和眼睛动画的插件,由两人组成的独立工作室(疯狂米诺工作室)开发。 插件全名为SALSA With RandomEyes,2014年上架Asset Store,目前是已下架,替换为新版本

里约热内驴的博客 1万+

HDOJ GCD Again 1787【欧拉函数】

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2625    Accepted Submission(s): 1099 Problem Description Do you have spent so

豫帝哥哥 1977

Arduino智能小灯DIY:人体感应+光线感应+蓝牙控制全攻略(附完整代码)

本文提供了一份完整的Arduino智能小灯DIY制作指南。项目融合了人体感应、光线感应与蓝牙控制三大功能,通过详细的硬件清单、电路连接图、核心逻辑讲解及附带的完整代码,手把手教你打造一个能自动感知环境与人、并支持手机远程控制的智能照明装置,是入门智能家居和物联网开发的绝佳实践。

java5的博客 1101

HDOJ 1787 GCD Again(欧拉函数)

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2611    Accepted Submission(s): 1090 Problem Description Do you have spent

Chunzhen的博客 1654

Python抓取摄像头图像,进行AI识别(一)

本文介绍了如何用Python获取海康威视摄像头的图像并进行AI识别。主要内容包括:1)准备工作,包括摄像头IP设置和密码重置方法;2)使用Python的Requests库通过ISAPI接口获取实时图像;3)示例代码展示如何保存摄像头图像。整个过程为后续AI图像识别提供了基础,通过简单的Python代码即可实现专业监控设备的图像采集功能。

Hahafantuan的博客 1520

真正的工业级环形缓冲区(Circular Buffer)完整实现细节

永远不要永远不要ToArray()或AddRange()永远返回或两段Span永远用_head_tail% Capacity实现环形照着上面这套代码改,你的系统将彻底告别内存爆炸,从“实验室玩具”变成“产线战神”!需要我给你一个支持两段绘制的完整实现吗?

专注于前沿技术的探索与实践,热衷于从代码逻辑、架构设计到行业应用等多维度深挖技术本质。期待在技术之路上与你共同成长~ 133

HDOJ1787 GCD Again-欧拉函数

题目大意:求1到n-1与n不互质数的个数题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1787Problem DescriptionDo you have spent some time to think and try to solve those unsolved problem after one ACM contest?No? Oh, you ...

。 266

YOLOv8的二次创新 | 结合iRMB与EMA打造全新的iEMA机制,提升动态检测性能【附保姆级代码】

YOLOv8继承了YOLO系列的轻量化和高效检测特性,同时通过改进的架构设计使得其在实时场景下具有更高的检测精度。然而,随着检测需求的增加,尤其是在动态目标检测和长时间序列检测中,YOLOv8的鲁棒性依然可以提升。通过iEMA机制的引入,我们将在这些方面进行进一步优化。iRMB模块是我们对传统Residual Block的进一步改进。通过多层特征提取,iRMB能够捕捉更多层次的特征信息,并通过引入轻量化的残差结构,提升计算效率。

一键难忘的博客 3094

hdoj1787GCD Again【欧拉函数】

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2666    Accepted Submission(s): 1120 Problem Description Do you have spen

走一步再走一步 625

Open3D——RANSAC 三维点云空间直线拟合【2025最新版】

使用RANSAC算法在点云数据中拟合三维空间直线的python代码实现。博客长期更新,本文最新更新时间为:2025年3月23日。

点云侠的博客 7361

XCP实战系列介绍07-使用ASAP2 Editor生成A2l文件详解

介绍通过ASAP2 Editor工具生成A2l文件步骤详解

initiallizer的博客 7314

hdoj GCD Again 1787 (欧拉函数)

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2716    Accepted Submission(s): 1143 Problem Description Do you have spent

yanghui07216的博客 476

SAP ABAP 获取采购订单未清数量/在途库存的 6 种方式

这篇文章我总结了获取采购订单未清数量/在途库存的 6 种方式,每种方式的优劣势和适用场景有所不同。读者请结合自身需要选择。

SAP李斌,本人承诺所有原创文章均不使用任何AI生成技术,请大家放心阅读。 2691

HDOJ-1787 GCD Again(欧拉函数)

ans=n-1-Eular(n) Eular(n)表示欧拉函数,[1,n]区间内与n互质的整数的个数 通式:Eular(x)=x(1-1/p1)(1-1/p2)(1-1/p3)(1-1/p4)…..(1-1/pn),其中p1, p2……pn为x的所有质因数,x是不为0的整数。 Eular(1)=1(唯一和1互质的数(小于等于1)就是1本身) 顺便提一下,有一个有意思的公式:一个数的

GoldMoon 716

OV9734 DATASHEET,完整规格书

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

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

hdoj 1787 GCD Again (欧拉函数模板 )

B - B(HDOJ 1787 GCD AGINE) Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Do you have spent some time to think and try to solve th

R 324

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

HDOJ 1787 GCD Again (欧拉函数)

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3169    Accepted Submission(s): 1400 Problem Description Do you have spent so

想飞的小菜鸡 359

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

HDOJ 1787 GCD Again (欧拉函数)

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2713    Accepted Submission(s): 1141 Problem Description Do you have spent so

滴水穿石,慢慢积累,总会有成果 629

HDOJ 题目1787 GCD Again(欧拉函数)

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2481    Accepted Submission(s): 1023 Problem Description Do you have spen

Jogging_Clown 471

HDOJ---1787 GCD Again[欧拉函数的延伸]

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1493    Accepted Submission(s): 560 Problem Description Do you have spent some time...

weixin_34357267的博客 107

HDOJ 1787 GCD Again (欧拉函数)求单个欧拉函数模板

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2713    Accepted Submission(s): 1141   Problem Description Do you have spent some ...

Sean 337

HDU 1787 GCD Again 欧拉函数

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2452    Accepted Submission(s): 1007 Problem Description Do you have spent so

小人物的草稿本 863

HDOJ--1787--GCD Again

题目描述: Do you have spent some time to think and try to solve those unsolved problem after one ACM contest? No? Oh, you must do this when you want to become a “Big Cattle”. Now you will find that this p...

猩猩是个好程序员的博客 154

hdu1787 GCD Again 欧拉函数在线算法 待补完

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3178    Accepted Submission(s): 1406 Problem Description Do you have spen

kyoma的博客 366

HDOJ-1787-GCD Again 解题报告

求欧拉函数单值,水题。题意:给你一个数n,求出大于0小于n的正整数中与n的最大公约数大于1的数的个数。        我的解题思路:与n的公约数大于1的数的个数就是与n不互素的数的个数。这里有个坑,首先就是小于n,因此输出应该是n - 1 - phi(n)。        我的解题代码: #include #include #include #include #inc

JZQT_T的博客 738

hdoj 1787《《欧拉函数》》

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2834    Accepted Submission(s): 1210 Problem Description Do you have spent so

leibniz_zhang的博客 459
上一篇: hdoj 1241 Oil Deposits
下一篇: 欧拉函数
SimonCoder
博客等级 码龄13年 1413粉丝 231原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址