Current location - Training Enrollment Network - Mathematics courses - Acm Mathematical Problems (Height Composite Number)
Acm Mathematical Problems (Height Composite Number)
I've thought about it for a long time ~ ~ First of all, it matters. The nth largest high composite number is obtained by multiplying the highest n- 1 high composite number by a prime number. Because, only the first 45, boldly only the first 10 prime number.

Initialized to 2, there are only 1 prime factors, and the number of factors is 2.

Then every time the factor of a number is greater than the current factor, this number is the next high composite number, and then this number is multiplied by the previous 10 prime numbers, and then pressed back into the heap. Until we find the top 45. Look at the code in detail.

# include & ltiostream & gt

# include & lt queue & gt

Use namespace std

Structural node

{

int fa[ 10];

int f;

int num

};

int zs[]={2,3,5,7, 1 1, 13, 17, 19,23,29 };

Priority queue & ltnode & gtq;;

Boolean operator < (node a, node b)

{

If (a.num! =b.num) returns a.num & gtb.num

Otherwise, return to a.f & gtb.f

}

int ans[50];

International;

Invalid transaction (node & A)

{

int I;

a . f = 1;

for(I = 0; I< 10; i++)a . f * = a . fa[I]+ 1;

}

Void initialization ()

{

Node temp, new _ one

int i,j;

for(I = 0; I< 10; i++)temp . fa[I]= 0;

temp . fa[0]= 1;

Transaction (temporary);

temp . num = 2;

q . push(temp);

al = 1;

int now _ f = 0;

And (al < = 46)

{

temp = q . top();

q . pop();

if(temp . f & gt; Now _f)

{

now _ f = temp.f

ans[al++]= temp . num;

for(I = 0; I< 10; i++)

{

temp . fa[I]++;

Temporary number * = zs [I];

Transaction (temporary);

q . push(temp);

temp . fa[I]-;

Temporary number/= zs [I];

}

}

}

}

int main()

{

init();

int n;

while(scanf("%d ",& ampn)! =EOF)

{

printf("%d\n ",ans[n]);

}

Returns 0;

}