#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;
const int maxn=6200000;
const int Max=1e8;
char book[(Max)>>3+50];
//int c[maxn]; // no delete?? ->re
LL output[200000];
struct Node
{
int id,n;
}a[12000];
bool cmp(Node p,Node q){return p.n<q.n;}
int cnt=0;
struct Node2
{
int val,gen;
}d[200000];
bool cmp2(Node2 p,Node2 q){return p.val<q.val;}
int jud(int x)
{
int Back=x&7;
int Pre=x>>3;
if(book[Pre]&(1<<Back)) return 0;
return 1;
}
void Set(int x)
{
int Back=x&7;
int Pre=x>>3;
book[Pre]=book[Pre]|(1<<Back);
}
int init()
{
memset(book,0,sizeof(book));
int tmp=sqrt(Max);
cnt=0;
for(int i=2;i<=tmp;i++)
{
if(jud(i))
{
for(int j=i+i;j<=Max;j=j+i)
{
if(jud(j)) Set(j); //j=26378238--stop??
//if(j>26378236) cout<<j<<endl;
}
for(long long int j=i*i;j<=Max;j=j*i)
{
d[cnt].gen=i;
d[cnt++].val=j;
}
}
}
sort(d,d+cnt,cmp2);
}
int main()
{
//freopen("C:/Users/hzy/Desktop/11.txt","r",stdout);
init();
int t;
scanf("%d",&t);
for(int i=0;i<t;i++) {scanf("%d",&a[i].n);a[i].id=i;}
sort(a,a+t,cmp);
unsigned int ans=1;
int st=0,p=0;
for(int i=2;i<=Max;i++)
{
if(jud(i)) {ans=ans*i;}
if(p<cnt&&d[p].val==i) {ans=ans*d[p].gen;p++;}
while(st<t&&i==a[st].n){output[a[st].id]=ans;st++;}
}
for(int i=0;i<t;i++) printf("%u\n",output[i]);
return 0;
}
位压缩
最新推荐文章于 2020-02-28 17:13:17 发布