#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
if(n<=0){
cout<<0<<endl;
continue;
}
vector<int> a,b;
long long sum=0;
for(int i=1;i<=sqrt(n);i++){
a.push_back(i);
b.push_back(n/i);
sum+=b[b.size()-1];
}
// if(sqrt(n)*sqrt(n)!=n)
sum+=(b[b.size()-1]-a[a.size()-1])*a[a.size()-1];
for(int i=sqrt(n)-1;i>0;i--){
sum+=(b[i-1]-b[i])*a[i-1];
}
cout<<sum<<endl;
}
}
#include <cmath>
#include <vector>
using namespace std;
int main(){
ios::sync_with_stdio(0);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
if(n<=0){
cout<<0<<endl;
continue;
}
vector<int> a,b;
long long sum=0;
for(int i=1;i<=sqrt(n);i++){
a.push_back(i);
b.push_back(n/i);
sum+=b[b.size()-1];
}
// if(sqrt(n)*sqrt(n)!=n)
sum+=(b[b.size()-1]-a[a.size()-1])*a[a.size()-1];
for(int i=sqrt(n)-1;i>0;i--){
sum+=(b[i-1]-b[i])*a[i-1];
}
cout<<sum<<endl;
}
}
Comments
Post a Comment