当前位置:网站首页>NEFU118 n! How many zeros are there after [basic theorem of arithmetic]
NEFU118 n! How many zeros are there after [basic theorem of arithmetic]
2022-07-27 14:55:00 【51CTO】
Topic link :
http://acm.nefu.edu.cn/JudgeOnline/problemshow.php?problem_id=118
The main idea of the topic :
ask : Calculation N! At the end of 0 The number of .(1 <= N <= 1000000000).
Ideas :
N yes 100000000 Number of scales , Direct calculation result , Re statistics 0 The number of is obviously unscientific . At the end 0 Decompose into 2*5.
every last 0 There must be a factor 5 Corresponding , But a factor in the factorization of a number 5 It doesn't necessarily correspond to one 0. because
Another factor is needed 2, To achieve one-to-one correspondence .
about N!, In factorization , factor 2 The number of is significantly larger than the factor 5 The number of . So if there is a factor 5, that
It must correspond to N! Last one 0. This problem becomes to find N! Medium factor 5 The number of . By the nature of the fundamental theorem of arithmetic (5)
You know :N! In prime factorization, prime numbers p The power of is [N/p] + [N/p^2] + [N/p^3] + …, You can directly cycle .
here ,5 It's a power of N! Medium factor 5 The number of , That is to say N! At the end of 0 The number of .
The definition and properties of the basic theorem of arithmetic are attached :
Theorem :
Each is greater than 1 The positive integer N Can be uniquely written as the product of primes , The prime factors in the product are arranged in non descending order .
Positive integer N Decomposition of N = p1^α1 * p2^α2 * p3^α3 * … * pk^αk be called N The standard decomposition of , among
p1,p2,…,pk Prime number ,p1 < p2 < p3 < … < pk, And α1,α2,α3,…,αk It's a positive integer. .
nature :
(1) if N The standard prime factorization expression of is :N = p1^α1 * p2^α2 * p3^α3 * … * pk^αk, set up d(N)
by N Number of silver earned , Φ(N) by N The sum of all the factors of , Then there are
d(N) = (α1 + 1) * (α2 + 1) * (α3 + 1) * … * (αk + 1)
Φ(N) = ( p1^(α1 + 1) )/(p1 - 1) * ( p2^(α2 + 1) )/(p2 - 1) * … * ( pk^(αk + 1) )/(pk - 1)
(2) set up a = α1 * p2^α2 * … * pk^αk,b = p1^ β1 * p2^β2 * … * pk^βk, Then there are
gcd(a,b) = p1^min(α1,β1) * p2^min(α2,β2) * … * pk^min(αk,βk)
lcm(a,b) = p1^max(α1,β1) * p2^max(α2,β2) * … * pk^max(αk,βk)
(3) If a and b It's a real number , be
max( gcd(a,b) ) + min( gcd(a,b) ) = a + b
(4) If a and b It's a positive integer. , be
lcm(a,b) = a*b/gcd(a,b)
(5)N! Prime numbers in the prime factorization of p The power of is
[N/p] + [N/p^2] + [N/p^3] + …
AC Code :
边栏推荐
- PROFINET 模拟器使用教程
- mysql保存数据提示:Out of range value for column错误
- 腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
- 数据库使用psql及jdbc进行远程连接,不定时自动断开的解决办法
- web上构建3d效果 基于three.js的实例
- [cache series] completely solve the problems of cache avalanche, breakdown and penetration
- Failed to connect to ResourceManager
- NEFU119 组合素数【算术基本定理】
- Document translation__ Tvreg V2: variational imaging method for denoising, deconvolution, repair and segmentation (part)
- Visual system design example (Halcon WinForm) -9. text display
猜你喜欢

Slam overview Reading Note 4: a survey on deep learning for localization and mapping: towards the age of spatial 2020

Visual system design example (Halcon WinForm) -10. PLC communication

一篇文章看懂JS执行上下文

Tencent two sides: @bean and @component are used in the same class, what will happen?

文献翻译__tvreg v2:用于去噪、反卷积、修复和分割的变分成像方法(部分)

【STM32】EXTI

Understand JS execution context in an article

@Bean 与 @Component 用在同一个类上,会发生什么?

Disk troubleshooting of kubernetes node

Stock trading 4
随机推荐
Hdu4496 d-city [concurrent search]
大家最想要的,最全的C语言知识点总结,还不赶紧学习
Hdu1422 revisits the world cup [DP]
JS what is declaration in advance? The order of function and variable declaration in advance (the foreshadowing of execution context)
获取Unity打开摄像头第一帧有画面的数据
DVWA全级别通关教程
Interprocess communication
Detoxify! After Harbin Institute of technology was disabled MATLAB, domestic industrial software fought back domineering
面试官问:如何判断一个元素是否在可视区域?
Graphical SQL is too vivid
OBS advanced DXGI acquisition screen process, and how to modify it to its own cursor
Shell programming specifications and variables
< C> C language hash table usage
一篇文章看懂JS执行上下文
2022 Niuke multi School II_ E I
codeforces 1708E - DFS Trees
Simple encapsulation steps of request data request of uniapp
JS什么是声明提前?函数与变量声明提前的先后顺序(执行上下文铺垫篇)
Understand the evolution of redis architecture in one article
FPGA时序约束分享04_output delay 约束