#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
const int N = 1001;
bool prime[N] = {true};
int d[1000001];//stores number of divisor
vector<int> p;
void sieve()
{
for(int i = 0; i <= N; i++)
prime[i] = true;
p.push_back(2);
for(int i = 2; i * i <= 1000; i++)
{
if(prime[i])
{
for(int j = i * i; j <= 1000; j += i)
{
prime[j] = false;
}
}
}
for(int i = 3; i <= N; i += 2)
{
if(prime[i])
p.push_back(i);
}
}
bool isPrime(int n)
{
if(n == 1)
return false;
for(int i = 0; i < p.size() && p[i] * p[i] <= n; i++)
{
if(n % p[i] == 0)
return false;
}
return true;
}
void divisor()
{
int num; //number of divisor
int result;
for(int i = 2; i <= 1000000; i++)
{
result = 1;
int temp = i;
for(int j = 0; j < p.size() && p[j] * p[j] <= temp; j++)
{
num = 0;
while((temp % p[j]) == 0)
{
num++;
temp = temp / p[j];
}
result *= (num + 1);
}
if(temp != 1)
result *= 2;
d[i] = result;
}
}
int main()
{
sieve();
divisor();
int c = 0;
for(int i = 2; i <= 1000000; i++)
{
for(int j = 0; j < p.size() && p[j] * p[j] <= d[i]; j++)
{
if(d[i] % p[j] == 0)
{
int x = d[i] / p[j];
if(x != p[j] && isPrime(x))
{
c++;
if(c % 9 == 0)
cout << i << endl;
break;
}
}
}
}
return 0;
}
#include <cstring>
#include <vector>
using namespace std;
const int N = 1001;
bool prime[N] = {true};
int d[1000001];//stores number of divisor
vector<int> p;
void sieve()
{
for(int i = 0; i <= N; i++)
prime[i] = true;
p.push_back(2);
for(int i = 2; i * i <= 1000; i++)
{
if(prime[i])
{
for(int j = i * i; j <= 1000; j += i)
{
prime[j] = false;
}
}
}
for(int i = 3; i <= N; i += 2)
{
if(prime[i])
p.push_back(i);
}
}
bool isPrime(int n)
{
if(n == 1)
return false;
for(int i = 0; i < p.size() && p[i] * p[i] <= n; i++)
{
if(n % p[i] == 0)
return false;
}
return true;
}
void divisor()
{
int num; //number of divisor
int result;
for(int i = 2; i <= 1000000; i++)
{
result = 1;
int temp = i;
for(int j = 0; j < p.size() && p[j] * p[j] <= temp; j++)
{
num = 0;
while((temp % p[j]) == 0)
{
num++;
temp = temp / p[j];
}
result *= (num + 1);
}
if(temp != 1)
result *= 2;
d[i] = result;
}
}
int main()
{
sieve();
divisor();
int c = 0;
for(int i = 2; i <= 1000000; i++)
{
for(int j = 0; j < p.size() && p[j] * p[j] <= d[i]; j++)
{
if(d[i] % p[j] == 0)
{
int x = d[i] / p[j];
if(x != p[j] && isPrime(x))
{
c++;
if(c % 9 == 0)
cout << i << endl;
break;
}
}
}
}
return 0;
}
Comments
Post a Comment