HDU 1124 Factorial

卡方分布的前世今生:一个统计概念的演化史 本文追溯了卡方分布从19世纪末的理论雏形到现代统计推断核心工具的发展历程。从Karl Pearson的数学奠基到Ronald Fisher的理论完善,卡方分布在医学研究、社会科学和机器学习等领域展现出广泛应用。文章通过代码示例和性质分析,揭示了这一统计概念如何持续推动数据科学创新。 阅读详情

解决该题要注意一下几个方面:

1、任何一个自然数都可分解质因数。N!=1*2*3*4*5*6*...*N=2^a*3^b*5^c*7^d......=(2*5)^c*2^(a-c)*3^b*7^d......=10^c*2^(a-c)*3^b*7^d......

2、两数相乘产生0,只会是2和5相乘。又由于在分解质因数时小的质数的幂次一定不小于大的质数的幂次大,所以a>=c。故解决该题转化成找出N!中5的幂次。

3、如何找出5的幂次呢?举例说明:N=26,阶乘中包含因数5、10、15、20、25,可知5的幂次为6。5=5*1,10=5*2,15=5*5,20=5*4,25=5*5,求解时用26/5=5,

再用5/5=1,再用1/5=0,所以总幂次为5+1+0=6。为什么可以这样求?在N!中数是连续增加的,5也是以其倍数渐进增加,一直增加到不大于N且是5的整数倍的最大整数。

这样一来就可以用N/5来确定出现多少个5了。当然,这还不够。比如26/5=5,与其幂次为6不符!原因在于25=5*5,其中含有2个5!所以,又有了紧接着的5/5=1,1/5=0了。

(最后这点解释的不够清楚,具体见代码,读者如有好的解释,也欢迎讨论!)

 

AC代码:52MS,输入输出用cin、cout就TLE了!

#include<iostream>
using namespace std;

int main()
{
	int t;

	scanf("%d",&t);
	while(t--)
	{
		int n,tmp=0;

		scanf("%d",&n);
		while(n)
		{
			tmp+=n/5;
			n/=5;
		}

		printf("%d\n",tmp);
	}

	return 0;
}


 

 

    

IPCP(IP Control Protocol,IP控制协议) 阅读详情

相关推荐

Claude Desktop Cowork国内实操指南:本地文件自动化办公

大语言模型正从‘问答式AI’迈向‘执行型协作者’,其核心能力在于直接操作本地文件、调用系统工具并嵌入真实工作流。Claude Desktop的Cowork模式正是这一范式的代表,它通过轻量沙箱VM实现对Excel、PPT、PDF、音视频等办公资产的读写与处理,无需手动编码即可完成数据清洗、会议纪要生成、自动化报告输出等任务。技术价值体现在权限可控、环境隔离、结果可交付;典型场景覆盖行政文秘的文档流转、销售运营的数据分析、开发者的脚本调试与环境验证。本文聚焦国内用户高频卡点——网络链路、系统权限与工作流断层,

weixin_30617737的博客 468

HDU 1124 因数

题意 传送门 HDU 1124 题解 N!N!N! 最右侧的连续 000 只可能由因数 2,52,52,5 构成,求 N!N!N! 中 2,52,52,5 能组成的最多个因数 101010 即可。 #include <algorithm> #include <cmath> #include <cstdio> #include <cstring> using namespace std; int T, N; int fac(int n, int d) {

neweryyy的博客 123

基于NE555的触摸延时开关电路设计与实现

本文详细介绍了基于NE555芯片的触摸延时开关电路设计与实现方法。通过分析NE555的单稳态工作模式,结合定时电阻、电解电容等关键元件选型,提供了一套完整的电路搭建方案。文章还包含抗干扰设计、调试技巧及常见故障处理,帮助电子爱好者快速掌握触摸延时灯的制作要点。

weixin_29268267的博客 791

Factorial

Problem Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular pho

No_Retreats的专栏 831

Cursor概述及环境配置

Cursor 是一款基于 AI 的代码编辑器,支持 VS Code 配置迁移和 Java 开发环境配置。主要功能分为 Cursor Settings(AI 相关设置)和 Editor Settings(基础编辑器设置)。用户可通过一键导入或手动方式迁移 VS Code 配置,配置包括主题、扩展和快捷键等。对于 Java 开发,需配置 JDK 和 Maven 路径,并安装 Java 扩展插件以获得完整开发体验,如代码补全、调试和 Maven 项目管理。此外,Cursor 支持汉化配置,用户可安装中文语言包切换

Knight 3558

四足机械臂避坑指南:从URDF配置到逆运动学控制的完整流程

本文为四足机械臂(Loco-Manipulation)系统开发提供了一份详实的实战避坑指南。文章深入剖析了从URDF模型配置、核心控制循环设计到逆运动学(IK)求解与奖励函数构建的完整流程,重点讲解了如何避免关节命名错误、惯性参数设置不当、IK求解不稳定等常见陷阱,并强调了利用collision_bbox等可视化工具进行高效调试的方法,旨在帮助工程师构建稳定、高效的四足机械臂控制系统。

weixin_42509507的博客 192

【奇妙的数论】HDU 1124 Factorial

[url]http://acm.hdu.edu.cn/showproblem.php?pid=1124[/url] [size=medium]题意:N阶乘有多少个尾0?(1

基德KID.1412 273

基于传输门与传输管逻辑的全加器设计

全加器是指对输入的两个二进制数相加(A与B)同时会输入一个低位传来的进位(Ci-1),得到和数(SUM)和进位(Ci)。一位全加器可以处理低位进位,并输出本位加法进位。由于这种晶体管的漏极和源极完全可以互换使用,因此这种电路的输入端与输出端也可以互换,这就是具有信号传输双向特性的传输管。传输管的输入信号可以传输到输出端,同时输出端的信号也可以传输到输入端。半加器是指对输入的两个一位二进制数相加(A与B),输出一个结果位(SUM)和进位(C),没有进位的输入加法器电路,是一个实现一位二进制数的加法电路。

qq_40353731的博客 4387

poj1401

题意:求n!有多少个0!!2*5会产生0,所以求出2和5中个数最小的既5的个数!! Factorial Description The most important part of a GSM network is so called Base Transceiver St

ACM 1336

华为产品安全基线

一、敏感信息安全传输 1、采用HTTPS安全协议传输 2、客户端本地保存的敏感信息,需要先加密再保存使用,不可逆支持PBKDF2(迭代10000次)加密保存,可逆支持AES256+IV保存,密钥支持可更新 二、认证鉴权 1、License中心与分析节点分布式部署,需要做用户名+口令安全认证,支持使用HTTPS安全协议。 2、客户端登录支持防暴力破解,支持验证码,多次连续尝试登陆失败后锁定账...

zileixu的博客 1万+

Holt-Winters方法预测水电发电量

Holt-Winters 模型, ARMIA,ACF检验 ,Dickey-Fuller 检测,白噪声检测,差分

firefox_yau的博客 1270

poj1401 Factorial

Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and ev...

weixin_30291791的博客 246

30.Labview如何读懂别人程序、修改程序?

之前写过一次教大家的文章,这次教大家如何学习别人的程序,和如何搭建一套适合自己的程序框架。这里事先说明一下:要想搭好程序框架,一定要先把自己的系统,逻辑是什么!这非常重要,是决定你程序的关键因素。废话不多扯,直接说重点。

关注我,更多技术问题欢迎私聊~ 2448

HDU HDOJ 1124 Factorial

HDU 1124 Factorial题目 找规律 N! 如此巨大的数 当然不可能 暴力求解

Gy_1096440940的博客 421

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

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

HDU 1124 Factorial

转载请注明出处:忆梦http://blog.youkuaiyun.com/yimeng2013/article/details/11822563 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1124 题意:计算N!中 0 的个数。 题解:0的个数,其实就是2*5的个数。 N!= 2^a * 3 ^b * 5 ^ c *……

忆梦 966

OV9734 DATASHEET,完整规格书

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

hdu 1124 Factorial

题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1124   题目描述: Factorial Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1955    Accepted Sub

心之所向,无惧无悔! 872

老版QQ原生表情gif动态

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

【HDU】 1124 Factorial

Factorial题目链接 Factorial 题目大意    题目扯了一大堆没用的,最后说让你求N!N!末尾有多少零。题解    末尾想产生零只有可能是2*5,所以我们找出min(num2,num5)就行了。     然而很明显2的数量肯定比5多,所以我们这里只用求5的数量就行了,所以我们用N整除5,25,125….最后加进答案中就行了。代码#include <iostream> #inclu

S_Black的专栏 608

Factorial HDU1124

题目: The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every pho...

Black_cat_look的博客 239

HDU-1124 Factorial

HDU-1124 Factorial AC代码及题解

包络面的博客 261

HDU1124 Factorial

Problem Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone)

_ 393

Factorial hdu 1124

 Problem DescriptionThe most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the stro

追求自由的码砖人 1495

hdu1124-Factorial

http://acm.hdu.edu.cn/showproblem.php?pid=1124 题意为求n!中个位出现0个个数的最大总和; 这也就意味着在中间过程中间所出现的所有情况都需要考虑,如果直接暴力,可能会TLE; 但是,如果要个位出现0的话,那么就一定是2和5的乘,又因为在因式分解的过程中,2的倍数一定会出现,所以只需要考虑5就可以了。 当数字为5~9时,由于阶乘的原因,一定会出现

bo-jwolf的专栏 1131

Factorial HDU - 1124

背景好多然而没什么用读题太慢了写题写少 求N!的末尾0的个数。 N!末尾的0是由2*5产生的。而且2因子的个数一定比5因子的个数多。所以只需要求N!的5因子的个数。 数论知识点: 1.若p是质数,p<=n,则n!是p的倍数, 2.设p^x是p在n!内的最高幂,则 x=[n/p]+[n/p2]+[n/p^3]+…; 3.[n/(ab)]=[[n/a]/b] #include<iostre...

weixin_43331783的博客 160

HDU 1124 Factorial

题目的意思是求垒乘以后的结果末尾有多少个0。 数据很大,不可能一次乘下去。所以必须考虑哪些值得乘积末尾是0, 1、首先是10的倍数的末尾一定有0; 2、末尾是5的可以乘以其他数的结果末尾为0;应该注意有25,50,75,(相距5*5=25个距离)这种数结尾的0要比其他的要多一个0; AC代码: #include #include #include using namespac

llbcys 828

HDU 1124 Factorial 【数论】

看到题目是求零的个数,0是2*5得到的,直接想到的是求2的个数和五的个数的最小值,但是超时了 正确做法(借鉴): 算数基本定理:任何一个大于1的自然数,都可以唯一分解成有限个质数的乘积 N!=1*2*3*4*5*6*7*……*n=1*2*3*2^2*2*3*…… 所以:2的个数一定比五多,所以最后只算五的个数就好,但是普通的算法依然超时 正确做法是直接求5的倍数。 例:50! 可以整...

han_hhh的博客 210
上一篇: HDU 1492 The number of divisors(约数) about Humble Numbers
下一篇: HDU 1214 圆桌会议
lulipeng_cpp
博客等级 码龄15年 169粉丝 130原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值