当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
正则表达式
djanjo fourth training
Flink Record has Long.MIN_VALUE timestamp (= no timestamp marker). Is the time characteristic
lvm建立逻辑卷
golang-channel-一个基础channel并行操作的简单函数
php生成二维码并下载图片(适应于框架)
文件包含漏洞-知识点
Offensive and defensive world - leaking
我的MySQL安装这样了怎么解决也
不一样的“能ping通不能上网”解决方法
Literature Learning (part33)--Clustering by fast search and find of density peaks
throw和throws区别
shell循环语句
The industry's first "Causal Inference Whole Process" Challenge!WAIC 2022 · Hackathon invites global developer elites to challenge
【回归预测】基于GPML工具箱的高斯过程回归附matlab代码
BLOB, TEXT, GEOMETRY or JSON column 'xxxx' can't have a default value
什么是DFT?FT、FS、DTFT、DFS、DFT的关系
Zigbee常见错误问题汇总
数据智能正当时,九章云极DataCanvas公司荣获“最具投资价值公司”
微软 .NET Core 3.1 年底将结束支持,请升级到.NET 6