题意求lcm(1,2,......,n)
给出测试组数T以及每一个lcm的n
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll unsigned int
using namespace std;
const int N=100000007;
int visit[N/32+50];;
int np,t,prime[5800000],n;
ll data[5800000];
void Prime ()
{
prime[0]=data[0]=2;
np=1;
for (int i=3;i<N;i+=2)
if (!(visit[i/32] & (1 << ((i/2)%16))))
{
prime[np]=i;
data[np]=data[np-1]*i;
np++;
for (int j=3*i;j<N;j+=2*i)
visit[j/32] |= (1 << ((j/2)%16));
}
}
void solve(int k)
{
int ans = upper_bound(prime,prime+np,k)-prime-1;
// printf("%d\n",ans);
ll temp= data[ans];
// printf("%d\n",temp);
for(int i=0; i<np&& prime[i]*prime[i] <= n; i++)
{
int mul = prime[i];
int tmp = prime[i]*prime[i];
while (tmp/mul == prime[i] && tmp<=n)
{
tmp *= prime[i];
mul *= prime[i];
}
temp*=(mul/prime[i]);
}
printf("%d\n",temp);
}
int main()
{
scanf("%d",&t);
Prime();
for(int i=1; i<=t; i++)
{
scanf("%d",&n);
printf("Case %d: ",i);
solve(n);
}
return 0;
}