#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int d[maxn],c[maxn],b[maxn];
int compute_primefactors(int n){
map<int,int>mp;
for(int d=2;d*d<=n;d++){
while(n%d==0){
mp[d]++;
n/=d;
}
}
if(n>1)
mp[n]++;
int sum=0;
for(auto it:mp){
sum+=it.second;
}
return sum;
}
void sum_of_exponents_of_prime_factors_of_x(int n){
for(int i=1;i<n;i++){
c[i]=compute_primefactors(i);
}
}
void precompute(){
int B_x=maxn;
sum_of_exponents_of_prime_factors_of_x(maxn);
d[1]=c[1];
for(int i=2;i<maxn;i++){
d[i]=d[i-1]+c[i];
}
}
int main(){
precompute();
int t;
cin>>t;
while(t--){
int x;
cin>>x;
cout<<d[x-1]+c[x];
}
}
coolph
2
Can you share your full code along with “input” using an online compiler.