Trailing Zeroes (II) LightOJ - 1090

数据库:关系运算整理大全(包括关系代数、元组关系演算、域关系演算) 数据库关系运算: 1. 关系代数(基本关系代数、附加关系代数、扩展关系代数) 2. 元组关系演算 3. 域关系演算 阅读详情

题目:Trailing Zeroes (II)  LightOJ - 1090 

题意:就是给你一个公式C(n, r)*p^q结果中有多少个0,但是题目中的顺序有点问题,我也是看别人的博客才看懂啥意思。

思路:本题的题意非常的简单,但是如何求取0的个数,一开始我看到C(n, r)就想到了Lucas定理,但是后来感觉不对,我就想到之前做过的题,也是类似的Trailing Zeroes (III) LightOJ - 1138 ,发现只需要求解2的个数和5的个数,然后取个数小的那一个。首先我们看C(n, r)中怎么求解5和2的个数,因为很容易利用x=[n/p]+[n/p^2]+[n/p^3]+…………;这个公式(算是公式吧)如果不明白请看上面的博客。那么p^q就比较好求了,只要求出p中有多少个2或者5,再乘以q,就是p^q中有多少个2或者5。

代码:

#include<bits/stdc++.h>
using namespace std;
#define LL long long
int ask(int x, int p)
{
    int ans = 0;
    while(x)
    {
        ans += x/p;
        x /= p;
    }
    return ans;
}
int Judge(int x, int p)
{
    int ans = 0;
    while(x % p == 0)
    {
        ans ++;
        x /= p;
    }
    return ans;
}
int main()
{
    int T, ca = 0;
    cin>>T;
    while(T--)
    {
        int n, r, p, q;
        cin>>n>>r>>p>>q;
        int total = ask(n, 2);
        int t = ask(n-r, 2);
        int k = ask(r, 2);
        total -= (t+k);
        int total1 = ask(n, 5);
        int t1 = ask(n-r, 5);
        int k1 = ask(r, 5);
        total1 -= (t1+k1);
        int a = Judge(p, 2);
        int b = Judge(p, 5);
        a *= q;
        b *= q;
        total += a;
        total1 += b;
        printf("Case %d: %d\n", ++ca, min(total, total1));
    }

    return 0;
}

 

物联网组网技术优缺点对比:蓝牙、LoRa、wifi、NB-IoT、ZigBee等 1.前言 最近对物联网产品自组网技术选型,找到合适的组网技术,让产品自行组网并完成数据的传输。 2.参数对比 阅读详情

相关推荐

告别混乱!用Juicebox和HiC-Pro玩转Hi-C数据可视化与比对(附Linux命令行实操)

本文详细介绍了如何使用Juicebox和HiC-Pro工具在Linux环境下高效处理Hi-C数据,包括数据可视化、比对分析和注释叠加。通过具体的命令行操作和技巧,帮助研究人员从原始数据生成高质量的互作热图,并实现差异比对与注释信息的整合,提升三维基因组研究的效率与准确性。

weixin_30329623的博客 488

LightOJ 1090 Trailing Zeroes (II) [分解]【数论】

题目链接 :http://acm.hust.edu.cn/vjudge/contest/view.action?cid=120197#problem/Y—————————————————–Trailing Zeroes (II) Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit St

Tabris的博客 590

Western blot (WB) 灰度分析进阶指南:ImageJ 高效定量技巧与实战优化

本文详细介绍了使用ImageJ进行Western blot灰度分析的进阶技巧,包括批量处理、背景校正和疑难条带处理等实战优化方法。通过自动化宏脚本和动态背景校正,显著提升分析效率和准确性,特别适合科研人员处理复杂WB数据。

weixin_42557830的博客 926

LightOj-1090-思路,分解,前缀和

找出这个数含有多少个2,或者5,然后最少有几对2*5就是有几个末尾0。 #include #include #include #include #include using namespace std; const int maxn=1e6+10; int t,n,r,p,q; int sum2[maxn],sum5[maxn]; void ini()//前1e6个数2.5的个数

alusang的博客 457

LTspice introduction - 2 LTspice的界面

LTspice的界面主要有两个:Schematic Capture和Waveform Viewer Schematic Capture 它主要是用来画电路图的,画完电路图之后,添加一些dot 命令同时选择一些仿真的参数,点击执行(Run)Waveform Viewer 如果你的仿真不是op point的话,一个都会打开它,在它里面你可以画图相应的图形。 有两种方式可以在Viewer

贾亮的专栏 3236

msf使用木马控制android手机

使用msfvenom生成木马控制手机

my_name_is_sy的博客 3531

LightOJ 1090 - Trailing Zeroes (II) (求式子结果0的个数)

1090 - Trailing Zeroes (II)   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Find the number of trailing zeroes for th

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

SAP RAP 校验全流程:从 EML 读取到消息上屏与阻止落库

本文系统梳理了 SAP ABAP RAP 中的校验流程(The Validation Process),结合 Airline/Connection 案例,详细讲解了三类核心校验:语义键唯一性、外键有效性和字段间一致性。文章覆盖了 EML 的 READ ENTITIES 操作、reported-* 与 failed-* 结构的使用方法、消息创建与字段绑定技巧,以及处理草稿数据时的 UNION 查询策略。通过代码示例演示了如何实现校验逻辑、生成错误消息并阻止无效数据持久化,同时提供了常见问题的排查建议。全文注重

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

【题解】LightOJ1090 Trailing Zeroes (II) 前缀和+数学知识

题目链接 预处理出阶乘的因子2和5的个数的前缀和 #include&amp;lt;cstdio&amp;gt; #include&amp;lt;algorithm&amp;gt; using namespace std; typedef long long ll; const int N=1e6; ll sum2[N+10],sum5[N+10]; void Init() { for(int i=2;i&amp;...

翻过这座山,他们就会听到你的故事 249

水与光的奇妙“切割之舞”:水导激光切割技术探秘

水导激光切割技术的诞生,是材料加工领域不断追求高精度、高质量加工的成果。传统激光切割技术在加工过程中,材料会因瞬间高温而产生热变形、热影响区大以及切割面粗糙等问题,这些弊端在对一些高精度、热敏性材料的加工中尤为突出 ,迫切需要一种新的技术来克服这些难题。水导激光切割技术的起源可以追溯到 20 世纪 80 年代。1986 年,德国公司 Aesculap-Werke AG 首次提出了将水流引入激光切割过程的创新想法,并制造出首代水导激光设备。不过,当时的技术尚处于雏形阶段,仅仅是在光纤出口添加了一小柱水流,激光

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 1685

基于ESP32的AI 古琴:基于音频指纹的民族乐器智能校准系统设计与实现

硬件选型兼顾实用性与低成本,接线简单易实现;基于 MFCC 的音频指纹算法,能有效识别古琴弦的音高特征;人机交互友好,新手可快速上手。

weixin_42300449的博客 314

Lightoj 1090 - Trailing Zeroes (II)

Trailing Zeroes (II) Find the number of trailing zeroes for the following function: nCr * pq where n, r, p, q are given. For example, if n = 10, r = 4, p = 1, q = 1, then the number is 210 so, number ...

我想要西瓜 301

DO-254标准详解:航空电子硬件设计保证指南全方位解析

RTCA DO-254, 也被称为《机载电子硬件设计保证指南》,是航空电子硬件设计和验证中的关键标准,旨在为确保机载电子硬件的安全性提供设计保证。自2000年首次发布以来,DO-254就成为了民航和军用飞机中电子硬件设计认证的基准文件。随着航空硬件技术的进步和日益复杂化,确保硬件设计的准确性、可靠性和安全性变得至关重要。本标准是由RTCA和EUROCAE共同开发的,适用于涉及机载硬件的航空公司、飞机制造商、供应商和认证机构。

qq_41854911的博客 3691

LightOJ 1090 Trailing Zeroes (II)

题目分析 这道题的意思就是让你求Crn∗pqC_n^r*p^q中末尾0的个数,那么很明显就是让你求算得的10的个数,而10能转化为2*5,那么我们就可以打表求10610^6范围内每个数可以表示成2和5分别的个数。 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespac

你真的介意真的在乎真的想要真的渴望的话你一定能够做到 265

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

lightoj 1090 - Trailing Zeroes (II)

Find the number of trailing zeroes for the following function: nCr * pq where n, r, p, q are given. For example, if n = 10, r = 4, p = 1, q = 1, then the number is 210 so, number of trailing zeroes

SSimpLe_Y的博客 792

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

LightOJ - 1090 Trailing Zeroes (II) 质因子分解

题意: 求 a = C(n, r) * ( p^q )  这个数字末尾有多少个 0  思路: 问题可以转化成 a 对10 进行分解,可以分解的次数, 即 对2分解 对5分解,两个中的较小值 预处理每个 1 - 1e6 的每个数字的对2分解,对5分解的次数,,然后还要保存下前缀和,作为 n的阶乘中分别包含的次数, #include #include #include #i

床前明月光 356

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

[尾随0个数]Trailing Zeroes (II) LightOJ1090

Find the number of trailing zeroes for the following function: C(n, r)*p^q where n, r, p, q are given as Input. Input Input starts with an integer T (≤ 10000), denoting the number of test cases. Each case contains four integers: n, r, p, q (1 ≤ n, r,

Cloth的博客 208

Trailing Zeroes (II) LightOJ - 1090(预处理+前缀和)

求C(n,r)*p^q的后缀零 考虑一下 是不是就是求 10^k*m 的k的最大值 而10又是由2 和 5 组成 所以即是求 2^k1 * 5^k2 * m1中k1和k2小的那一个数 短板效应嘛。。预处理每个 1 - 1e6的每个数字的对2分解,对5分解的次数 然后还要保存下前缀和 作为n的阶乘中分别包含的次数 #include <iostream> #i...

weixin_30797199的博客 92

LightOJ-1090-数论

题目大意:求C(n,r)*(p^q)末尾有几个0; 题目解析:转化一下,就是求k*10^x的x的最大值,在转化一下,就是求(2^m1)*(5^m2)*k中m1和m2的最小值; AC代码: #include #include #include #include #include using namespace std; const int maxn=1000010; int two[maxn]

zyz_3_14159的博客 451

Trailing Zeroes

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! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the tr...

weixin_43154720的博客 287

Trailing Zeroes (II)

Find the number of trailing zeroes for the following function: nCr* pq wheren, r, p, qare given. For example, ifn = 10, r = 4, p = 1, q =...

Angeliaaa的博客 418

【数论】Trailing Zeroes (III)

Trailing Zeroes (III)????点击打开题目 You task is to find minimal natural numberN, so thatN!contains exactlyQzeroes on the trail in decimal notation. As you knowN! = 1*2*...*N. For example, 5! = 120, 12...

1209

【LightOJ 】 Trailing Zeroes (I) (II) (III) 【数论 】

Trailing Zeroes (I) We know what a base of a number is and what the properties are. For example, we use decimal number system, where the base is 10 and we use the symbols - {0, 1, 2, 3, 4, 5, 6, 7,...

lzs_lazy 473

Trailing Zeroes (II) (求末尾0的个数)

Find the number of trailing zeroes for the following function: nCr* pq wheren, r, p, qare given. For example, ifn = 10, r = 4, p = 1, q = 1, then the number is210so, number of trailing zeroes ...

自渡的博客 333
上一篇: Combinations LightOJ - 1067
下一篇: A New Function LightOJ - 1098
Re:fused
博客等级 码龄9年 474粉丝 162原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址