What is the minimum number of factors in the inverse prime number template?

Source: Internet
Author: User

Antiprime Number:

If a natural number is more than the number of all natural numbers smaller than it, then we call this number a antiprime number. For example, values 1, 2, 4, 6, 12, and 24 are inverse prime numbers.

 

The maximum antiprime Number of N is as follows:

# Include <math. h >#include <iostream> using namespace STD; # define ll _ int64const LL Prime [16] = {1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47}; ll maxsum, bestnum, N; void DFS (LL num, ll K, ll sum, ll limit) // num: the number currently enumerated. K: the prime factor of the K enumerated. Sum: the approximate number of the numbers. Limit: the maximum number of quality factors; {int I; ll TMP; If (sum> maxsum) {maxsum = sum; bestnum = num; // if there are more approx., update the optimal solution to the current number ;} if (sum = maxsum & bestnum> num) {// If the approximate number is the same, update the optimal solution to a smaller number; bestnum = num;} If (k> 15) return; TMP = num; for (I = 1; I <= limit; ++ I) {// start to enumerate the number of each prime factor if (TMP * prime [k]> N) {break;} TMP * = prime [k]; // accumulate to the current number DFS (TMP, k + 1, sum * (I + 1), I); // continue the next search} int main () {ll I, j; int N; CIN> N; DFS (1, 1, 1, 50); printf ("% LLD \ n", bestnum ); return 0 ;}

The following table can be used to calculate 1-1000 or more inverse prime numbers (just change the array size)

# Include <iostream> # include <cstdio> # include <algorithm> # include <cmath> # include <cstring> using namespace STD; typedef _ int64 LLD; lld p [1010]; // P [I] indicates the smallest integer of the number of factors I. What is LLD prime [30] = {2, 3, 5, 7, 11, 13, 17, 19, 29, 31,37, 41,43, 47,53}; int maxn; // the maximum possible value void getartprime (LLD cur, int CNT, int limit, int K) {// cur: the number currently enumerated; // CNT: the number of factors involved; // limit: the upper limit of the number of factors; 2 ^ T1 * 3 ^ T2 * 5 ^ T3 ...... T1> = T2> = T3 ...... Generally, 50 is enough. // The Prime Number of K. // If (cur> (LLD) 1 <60) | CNT> 150) return; if (cur> maxn) return; // if the current number is greater than the maximum number we require, maxn will be able to search for it. If (P [CNT]! = 0 & P [CNT]> cur) // The number of current factors has been recorded and the number of records at that time is greater than the number currently enumerated, then, replace the enumerated number P [CNT] = cur under the number of this factor; If (P [CNT] = 0) // the number of this factor has not appeared, P [CNT] = cur; LLD temp = cur; For (INT I = 1; I <= limit; I ++) // enumeration count {temp = temp * prime [k]; If (temp> maxn) return; getartprime (temp, CNT * (I + 1), I, k + 1) ;}} int main () {getartprime (, 50, 0); Return 0 ;}

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.