Transmission Door
Test instructions
Give you a number k, the first k non-complete square number starting from 1.
Defines a number as a complete square number if and only if the number factor decomposition exists two times.
such as: 4=22 4=2^2 is a complete square number, 30=2∗3∗5 30=2*3*5 is a non-complete square number.
Exercises
1. Starting from 1 K non-complete square number ⇔\leftrightarrow min (n) min (n), the number of non-complete squares smaller than n n is K. With this nature, two points can be made.
2. n N Small non-complete square number of =∑i=1n√μ (i) ∗ni2 \sum_{i=1}^{\sqrt{n}}\mu (i) *\frac{n}{i^2}
The essence of the formula above is the repulsion.
The first minus factorization contains 22,32,42,52 ... The number of 2^2,3^2,4^2,5^2, plus the number that contains 22∗32 2^2*3^2, and so on.
for μ (d) \mu (d) can be sifted out in the linear time class.
It is not difficult to find the time complexity of O (t∗n√∗logn+n) O (t*\sqrt{n}*log\,n+n)
Writing code is schmalensee. Also put the prefix and forget it. In fact, for Ni2 \frac{n}{i^2} The same segment is very small, or n√\sqrt{n} level, rather than direct enumeration simple. Code
#include <bits/stdc++.h> using namespace std;
typedef long Long LL;
const int MAXN=5E4;
inline int read () {char ch=getchar (); int i=0,f=1;
while (!isdigit (CH)) {if (ch== '-') F=-1;ch=getchar ();}
while (IsDigit (ch)) {i= (i<<1) + (i<<3) +ch-' 0 '; Ch=getchar ();}
return i*f;
} int prime[maxn+50],pr[maxn+50],tot,mu[maxn+50];
inline void sieve () {mu[1]=1;
for (int i=2;i<=maxn;i++) {if (!pr[i]) {prime[++tot]=i;pr[i]=i;mu[i]=-1;}
for (int j=1;j<=tot;j++) {int k=i*prime[j];
if (K>MAXN) break;
PR[K]=PRIME[J];
if (I%prime[j]) {mu[k]=-mu[i];}
else {mu[k]=0;break;}
}} for (int i=1;i<=maxn;i++) mu[i]+=mu[i-1];
} Inline ll calc (int n) {int lim=sqrt (n);
int POS;
ll Ans=0;
for (int bg=1;bg<=lim;bg=pos+1) {pos=min (lim, (int) sqrt (n/(N/BG/BG)));
ans+=1ll* (N/BG/BG) * (Mu[pos]-mu[bg-1]);
} return ans; } int main () {SiEve ();
int T=read (); while (t--) {int