lightoj-1138-Trailing Zeroes (III) -二分查找

iOS马甲包过审实战:如何用5天时间搞定4.3审核(附完整代码混淆方案) 本文提供了一套为期五天的高效实战方案,专门解决iOS应用因重复或抄袭问题而被App Store的4.3条款拒绝的难题。方案涵盖深度分析、代码混淆、资源翻新及环境隔离等系统性步骤,并附有完整的代码混淆示例,旨在帮助开发者在合规框架内重塑应用,显著提升过审成功率。 阅读详情

题目传送门:https://vjudge.net/problem/LightOJ-1138



题意:给你一个数字,这个数字代表N!后面有几个0。给出这个数字,计算N的值。

解题思路:
任何质因数都可以写成素数相乘的形式。所以计算一个数的阶乘后面几个0,只需计算这个数包含多少5即可。


ac代码;

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define inf 0x3f3f3f3f
#define N 500000000
typedef long long ll;
using namespace std;
 
int ok(int x)
{
    int sum = 0;
    while(x)
    {
        sum = sum + x/5;
        x /= 5;
    }
    return sum;
}
 
int main()
{
    int T;
    scanf("%d", &T);
    for(int i = 1; i <= T; i++)
    {
        int n;
        scanf("%d", &n);
 
        int l = 0, r = N, mid;
        while(l <= r)
        {
            mid = (l + r) /2;
            int b = ok(mid);
            if(b >= n)
            {
                r = mid-1;
            }
            else
            {
                l = mid+1;
            }
        }
        if(ok(l) == n)
            printf("Case %d: %d\n", i, l);
        else
            printf("Case %d: no\n", i);
    }
    return 0;
}


车载LIN总线避坑指南:主从节点通信失败的5个常见原因及解决方案 本文深度解析车载LIN总线主从节点通信失败的五大常见原因,涵盖物理层信号异常、调度表冲突、LDF配置错误、节点状态机缺陷及环境干扰。重点剖析了LDF文件配置不一致、波特率不匹配等关键问题,并提供了从示波器波形分析到软件配置检查的完整实战排查路径,帮助工程师高效定位并解决LIN通信故障。 阅读详情

相关推荐

让AI镜头“活”起来:22个核心运镜提示词,告别视频画面呆板

介绍了22种影视级镜头语言的AI提示词用法。内容涵盖推轨/后拉镜头等距离变化技巧、横摇/俯仰等方向控制手法、环绕/升降等空间位移方式,以及POV视角等特殊构图。

weixin_43489601的博客 6318

二分查找(Trailing Zeroes (III)(LightOJ1138))

二分查找:在有序数组中,寻找特定数的的算法。 步骤: 先在判断当前数组 中间值mid(mid=left+(right-left)/2))是否等于所找数字n,若是,返回mid。 若不是,n>fx(mid),说明n在数组靠近right的部分,left=mid+1;n<mid,n在数组靠近left部分,right=mid-1;继续进行1中的判断。 进入循环的条件是:while(lef...

智慧园子的代码世界 216

Linux安装部署PostgreSQL详细步骤

Linux安装部署PostgreSQL详细步骤

2301_77356579的博客 9339

Trailing Zeroes (III) LightOJ - 1138 (阶乘中某质因子的幂+二分查找)

题目:Trailing Zeroes (III)LightOJ - 1138 题意:在计算N!的时候会产生Q个0,那么如果我知道Q是多少,请问这个数N是多少?如果存在把N输出,不存在直接输出impossible。 思想:在计算阶乘的时候如何判断结果有几个0?首先看看5! = 1*2*3*4*5=120,发没发现什么规律,没错就是因子为2和5个数的最小值,因为2的个数一定比5的个数多...

REfusing的博客 320

8.Python基础语法(五)续【光说不练假把式,上题】

Python基础语法(二) 有关于Python循环语句的几道实操,让大家理解知识点更深更透彻~

孤寒者的博客 2万+

智驾芯片新天团!NVIDIA Thor vs 高通8797 vs 蔚来神玑NX9031,2025-2026谁能称王?

应用场景推荐芯片理由高阶NOA + L4 Robotaxi千TOPS以上,满足BEV+TransformerL2+/L3级别NOAThor-U / 高通8797算力适中,功耗控制佳,生态成熟经济型城市NOAThor-Z / S性价比均衡,适合前装普及自研平台一体化NX9031华为之外最强自研整合方案📌 TOPS不再是天花板,GPU、带宽、功耗、上市时间和车企绑定都是决胜关键📌 Thor系列仍然统治高端,但国产神经元开始觉醒📌 智驾芯片的选择,从“强”走向“适合场景”

weixin_43199439的博客 2689

lightoj- 1138 - Trailing Zeroes (III)【思维】【二分查找】

题目链接:点击打开链接 1138 - Trailing Zeroes (III)     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You task is to find minimal natural nu

_Somethingwill 529

RAG 实战:LangChain + 向量数据库构建知识问答系统

从文档加载、分割、嵌入到检索增强生成,完整实现一个基于本地文档的知识问答系统。

kaixin110a的博客 194

LightOJ 1138 Trailing Zeroes (III) 二分查找

线性变化可以想二分。 末尾的0的个数只和5有关。

YueLing's Blog 457

TextView部分文字可以被点击的效果。TextView拼接图片,图片可以被点击

今有一需求,就是列表标题后拼接图标,点击图标跳转一个web页; 这里简单做下笔记,以供需要的人参考: //设置部分文字点击事件 ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View widget) { Toast.makeText(conte...

LXFX1108的专栏 701

疾风气象大模型4.0白皮书

《疾风气象大模型白皮书摘要》 疾风气象大模型(J-AFM)是国内首个基于3D建模的气象智能平台,突破传统二维气象分析的局限,采用体素化技术构建"x-y-z-t"四维统一模型,实现从分钟级短临到30天跨时效的连续预测。核心技术包括:1)多源数据三维同化,融合雷达、卫星、风廓线等异构数据;2)物理约束AI解码器,嵌入能量守恒、湍流封闭等气象原理;3)行业适配插件,服务风电、光伏、航空等领域,如山地风场尾流校正、云影短临预测。平台支持批流一体推理与边缘部署,提供概率化输出和误差溯源能力,显著降

专注AI大模型,软件混淆,授权 558

LightOJ1138 Trailing Zeroes (III) 二分

LightOJ1138 Trailing Zeroes (III) 标签 二分 前言 我的csdn和博客园是同步的,欢迎来访danzh-博客园~ 简明题意 给定q(q<=1e8),问使得n!的末位有q个0的最小n。 思路 一个数末尾有q个0,意味着对这个数质因数分解,2和5的指数的最小值==q。 注意到在n!中, 注意事项 总结 一个数末尾有q个0,意味着对这...

danzh 181

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

LightOJ 1138 Trailing Zeroes (III)

LightOJ 1138 Trailing Zeroes (III) 题目链接 You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 12…*N. For example, 5! = 120, 120 contains one zero on the trail. Input Input star

旺崽的博客 2599

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

lwip-2.0.3

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

LightOJ 1138 Trailing Zeroes (III) (数论)

LightOJ 1138 Trailing Zeroes (III) 题目连接:https://vjudge.net/problem/LightOJ-1138 题目描述: 给你一个数 q,让你求出一个数 n , 使得 n! 末位的0的个数为 q 。 解题思路: 首先我们来看一段证明: 一个数阶乘 末位零的个数。 我们可以知道 2 * 5 得到 一个末位 0 的; 同理 22 * 52 得到两个末位 0 ; …… 2n * 5n 得到 n个末位 0; 在阶乘中 2的个数一定大于 5的个数。 所以

qq_45095009的博客 284

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

N - Trailing Zeroes (III) LightOJ - 1138

N - Trailing Zeroes (III) LightOJ - 1138 二分+找5的个数。找5的个数用了一个很巧妙的方法,先找5的倍数的数,再找25倍数的数,直到0。 二分写的好烂,交了好几遍 1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 ...

weixin_30355437的博客 91

LightOJ - 1138 - Trailing Zeroes (III) (二分)

题目链接---LightOJ-1138                                                                1138 - Trailing Zeroes (III)   PDF (English)StatisticsForumTime Limit: 2 second(s)Memory Limit: 32 MBYou task is to f...

NSSWTT的博客 346

lightoj-【1138 - Trailing Zeroes (III)】

1138 - Trailing Zeroes (III)     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You task is to find minimal natural number N, so th

有梦的博客 355

LightOJ 1138 - Trailing Zeroes (III)【二分】

1138 - Trailing Zeroes (III)     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You task is to find minimal natural number N, so th

博客已搬迁到http://www.cnblogs.com/cniwoq/ 341

LightOJ 1138 Trailing Zeroes (III)

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=70017#overview Trailing Zeroes (III) Description You task is to find minimal natural number N, so that N! contains exactly Q 

大太阳 592

Light OJ 1138 Trailing Zeroes (III)

题目链接 http://lightoj.com/volume_showproblem.php?problem=1138 1138 - Trailing Zeroes (III)     PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB You task is ...

Source_Roc 201

lightoj 1138 - Trailing Zeroes (III)(规律+二分)

链接:http://lightoj.com/volume_showproblem.php?problem=1138非常基础的一道题,首先n的阶乘的末尾的零是靠5*2出现的,所以只需统计有多少个5就行了 由于数据较大 故用二分搜索 大致猜个范围 套下模板就能过 做的时候没看清题目说的是末尾的零以为是全部零orz。。。代码:#include&lt;cstdio&gt; #include&lt;stri...

weixin_39302444的博客 237

LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)

http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MSMemory Limit:32768KB64bit IO Format:%lld & %llu SubmitStatusPracticeLightOJ 113...

deyou1988的专栏 154

Trailing Zeroes (III) LightOJ - 1138

思路:二分统计5的个数 #include <bits/stdc++.h> #define int long long using namespace std; const int32_t N = 1e7 + 10; int t, n; int f5(int x) { //统计当前数中5的个数 int ans = 0; while(x) { ans +...

Endeavor_G的博客 252

Light oj 1138 - Trailing Zeroes (III)

题目:Light oj 1138 - Trailing Zeroes (III) 思路:二分+暴力+求阶乘中某质因子的幂 #include #include #include #include #include #include using namespace std; long long n; long long get_5(long long n) { long

shiyuan的专栏 1303
上一篇: lightoj-1234-调和级数
下一篇: 三点求平面方程、平面法向量和点到平面的距离
Bigdz
博客等级 码龄10年 10粉丝 33原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址