#include<bits/stdc++.h>
using namespace std;
const int N = 1e7;
bool comp[N];
vector<int>primes;
void oldsieve()
{
memset(comp,0,sizeof comp);
primes.clear();
for(int i=2;i<N;i++)
if(!comp[i])
{
primes.push_back(i);
for(int j=i*2;j<N;j+=i)
comp[j]=1;
}
}
void newsieve()
{
memset(comp,0,sizeof comp);
primes.clear();
for(int i=2;i<N;i++)
{
if(!comp[i])
primes.push_back(i);
for(int j=0,si=primes.size();j<si&&i*primes[j]<N;j++)
{
comp[primes[j]*i]=1;
if(i%primes[j]==0)break;
}
}
}
int main()
{
time_t t0;
time(&t0);
oldsieve();
//for(int i=0;i<20;i++)cout<<primes[i]<<' ';cout<<endl;
newsieve();
//for(int i=0;i<20;i++)cout<<primes[i]<<' ';cout<<endl;
time_t t1;
time(&t1);
double seconds = difftime(t1,t0);
printf("%.7f",seconds);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IE4gPSAxZTc7CmJvb2wgY29tcFtOXTsKdmVjdG9yPGludD5wcmltZXM7CnZvaWQgb2xkc2lldmUoKQp7CiAgICBtZW1zZXQoY29tcCwwLHNpemVvZiBjb21wKTsKICAgIHByaW1lcy5jbGVhcigpOwogICAgZm9yKGludCBpPTI7aTxOO2krKykKICAgICAgICBpZighY29tcFtpXSkKICAgICAgICB7CiAgICAgICAgICAgIHByaW1lcy5wdXNoX2JhY2soaSk7CiAgICAgICAgICAgIGZvcihpbnQgaj1pKjI7ajxOO2orPWkpCiAgICAgICAgICAgICAgICBjb21wW2pdPTE7CiAgICAgICAgfQp9CnZvaWQgbmV3c2lldmUoKQp7CiAgICBtZW1zZXQoY29tcCwwLHNpemVvZiBjb21wKTsKICAgIHByaW1lcy5jbGVhcigpOwogICAgZm9yKGludCBpPTI7aTxOO2krKykKICAgIHsKICAgICAgICBpZighY29tcFtpXSkKICAgICAgICAgICAgcHJpbWVzLnB1c2hfYmFjayhpKTsKICAgICAgICAgICAgZm9yKGludCBqPTAsc2k9cHJpbWVzLnNpemUoKTtqPHNpJiZpKnByaW1lc1tqXTxOO2orKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY29tcFtwcmltZXNbal0qaV09MTsKICAgICAgICAgICAgICAgIGlmKGklcHJpbWVzW2pdPT0wKWJyZWFrOwogICAgICAgICAgICB9CiAgICB9Cn0KaW50IG1haW4oKQp7CiAgICB0aW1lX3QgdDA7CiAgICB0aW1lKCZ0MCk7CiAgICBvbGRzaWV2ZSgpOwogICAgLy9mb3IoaW50IGk9MDtpPDIwO2krKyljb3V0PDxwcmltZXNbaV08PCcgJztjb3V0PDxlbmRsOwogICAgbmV3c2lldmUoKTsKICAgIC8vZm9yKGludCBpPTA7aTwyMDtpKyspY291dDw8cHJpbWVzW2ldPDwnICc7Y291dDw8ZW5kbDsKICAgIHRpbWVfdCB0MTsKICAgIHRpbWUoJnQxKTsKICAgIGRvdWJsZSBzZWNvbmRzID0gZGlmZnRpbWUodDEsdDApOwogICAgcHJpbnRmKCIlLjdmIixzZWNvbmRzKTsKfQ==