当前位置:网站首页>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 :
边栏推荐
- 股票买卖4
- Idea makes jar packages and introduces jar packages
- 视觉系统设计实例(halcon-winform)-9.文字显示
- Get the data of the first frame of unity's open camera
- Dynamic programming - stock trading 5
- UnityUI方面处理(归纳与积累)
- DXGI 方式采集流程
- Airport cloud business sign analysis
- Why is there no unified quotation for third-party testing fees of software products?
- Regular expressions: mailbox matching
猜你喜欢
![[ManageEngine] what is Siem](/img/a6/0fbe60df6bef337a91a10fe046aa8a.jpg)
[ManageEngine] what is Siem

面试官问:如何判断一个元素是否在可视区域?
![[intensive reading of papers] grounded language image pre training (glip)](/img/3a/4ad136065acb8627df9e064ed8ef32.png)
[intensive reading of papers] grounded language image pre training (glip)

在Oracle VirtualBox中导入Kali Linux官方制作的虚拟机

Arduino+ze08-ch2o formaldehyde module, output formaldehyde content

图解 SQL,这也太形象了吧

How to do well in enterprise system vulnerability assessment

Redis

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

Lecture 4: Longest ascending substring
随机推荐
@Bean 与 @Component 用在同一个类上,会发生什么?
Why is there no unified quotation for third-party testing fees of software products?
CPU、GPU、NPU的区别
Simple encapsulation steps of request data request of uniapp
PROFINET simulator tutorial
Differences among CPU, GPU and NPU
一文搞懂 Redis 架构演化之路
Architecture - the sublimation of MVC
【云享读书会第13期】视频文件的封装格式
va_ List usage summary
Chinese character style transfer --- antagonistic discriminative domain adaptation (L1)
Forward proxy and reverse proxy
Stock trading 4
Slam overview Reading Note 7: visual and visual intangible slam: state of the art, classification, and empirical 2021
Hard deduction SQL statement exercises, wrong question records
【STM32】EXTI
JS epidemic at home, learning can't stop, 7000 word long text to help you thoroughly understand the prototype and prototype chain
Who can't capture packets these days? Wireshark packet capture and common protocol analysis are for you!
Get the data of the first frame of unity's open camera
Web page table table, realizing rapid filtering