版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/V5ZSQ/article/details/83301756
Description
给个 ,求 到 的所有数的约数个数的和~
Input
第一行一个正整数
Output
输出一个整数,表示答案
Sample Input
3
Sample Output
5
Solution
,分块加速或者直接求都行
Code
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
int n;
scanf("%d",&n);
ll ans=0;
for(int i=1,pre;i<=n;i=pre+1)
{
pre=n/(n/i);
ans+=1ll*(n/i)*(pre-i+1);
}
printf("%lld\n",ans);
return 0;
}