当前位置:网站首页>ACWing 198. Antiprime Problem Solution
ACWing 198. Antiprime Problem Solution
2022-08-08 08:23:00 【The second son of peak is not little brother】
Difficulty: Medium
Title
For any positive integer x, the number of its divisors is written as g(x), such as g(1)=1, g(6)=4.
If a positive integer x satisfies: for any positive integer i less than x, there is g(x)>g(i), then x is called an inverse prime number.
For example, the integers 1, 2, 4, 6, etc. are all inverse primes.
Now given a number N, request the largest inverse prime number not exceeding N.
Input format
A positive integer N.
Output format
An integer representing the largest antiprime number not exceeding N.
Data Range
1≤N≤2∗10^9
Sample input:
1000
Sample output:
840
Prefix knowledge
Unique Decomposition Theorem (Basic Theorem of Arithmetic): Any natural number N greater than 1 can be uniquely decomposed into the product of finite prime numbers
In the Fundamental Theorem of Arithmetic, if a positive integer N is uniquely decomposed into N = , where ci are all positive integers, pi are all prime numbers, and satisfy p1 { The number of positive divisors of N is (Π represents the symbol of continuous product, similar to ∑): (c1 + 1) * (c2 + 1) *...* (cm + 1) = The sum of all positive divisors of N is: The inhomogeneity factor of an inverse prime number will not exceed 10, because 2*3*5*7*11*13*17*19*23*29*31>2*10^9 all prime factors of an inverse prime numberThe sum of the exponents does not exceed 30, because 2^31>2*10^9.Therefore, you can use recursive DFS to violently search for all possible combinations of the exponents of the first ten prime numbers. When searching, the exponents should be monotonically decreasing, the total product should not exceed N, and the number of current divisors should be recorded at the same time.. There are two very important properties for antiprimes}, where 0 ≤ bi ≤ ci
Solution ideas
Code Example
#include
边栏推荐
猜你喜欢
随机推荐
LabVIEW前面板和程序框图的最大尺寸
oracle sql语法 更改为mysql sql语法 或者代码实现
2022/8/7
IIC通讯协议与EEPROM简介
Data Governance (3): Data Quality Management
HTTS 为什么更安全?
【vulhub】PostGresql高权限命令执行漏洞复现(CVE-2019-9193)
优雅地处理重复请求(并发请求)
机器学习理论及案例分析(part3)--聚类
教你实现多线程案例定时器
nodeJs--egg框架介绍
Gstreamer调试方式
关于#sql#的问题:kingwow数据库
攻防世界——web2
用于一型糖尿病血糖调节的无模型iPID控制器
Implementation principle of priority queue
音视频入门知识-- --相关名词、术语、概念
超强企业建站系统介绍:五大特点
制作SD启动卡,从SD卡启动系统
DVWA full level detailed customs clearance tutorial