Topic Background
Positive integer n is infinite, but some of these numbers have magical properties, we give it a name--ap number. Topic Description
The necessary and sufficient condition for a number i is an AP number is that all of the number of factors that are smaller than it are not the number of I. For example, the factor of 6 is 1 2 3 6 Total has 4 factor. It is an AP number (1-5 of the number of factors is not 2 or 3). The task of our topic is to find a maximum number of AP that is no more than N. Input output format input format:
Each test point may have multiple sets of data.
For each row there is an N, as described in the topic
Output format:
For each line of the maximum number of AP and no more than n
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
Long long N,AP,FAP;
int mm[30]={2,3,5,7,11,13,17,19,23,29};
void Dfs (Long long num,long long Fnum,long long I,long long j)
{
if fap<fnum| | (fap==fnum&&ap>num))
{
fap=fnum;
Ap=num;
}
int t=1;
while (t<=j&&num*mm[i]<=n)
{
num*=mm[i];
DFS (num,fnum* (t+1), i+1,t);
t++;
}
return;
}
int main ()
{
while (~scanf ("%lld", &n))
{
ap=0;
Fap=0;
DFS (1,1,0,20);
cout<<ap<<endl;
}
} AP=AP/3; ap=ap*3; AP=AP/11; ap=ap*11;