1~N的约数之和(数论,分块)
https://ac.nowcoder.com/acm/contest/114408/A
数论知识:https://oi-wiki.org/math/

重要的转换芝士
挺板的
点击查看代码
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
int n;
cin>>n;
int l=1,r=0;
int res=0;
while(l<=n)
{
r=n/(n/l);
res=res+(n/l)*(r-l+1ll);
l=r+1;
}
cout<<res;
return 0;
}

浙公网安备 33010602011771号