版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_38013346/article/details/82077960
代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
int main()
{
ll n;int caset;
scanf("%d",&caset);
while(caset--) {
scanf("%lld",&n);
ll res = 0;
for(int i=1;i<=n;) {
int r = n/(n/i);
res += (n/i) * (r + i) * (r - i + 1) / 2 ;
i = r+1;
}
printf("%lld\n",res);
}
return 0;
}