题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1257
\( n\%i = n - \left \lfloor n/i \right \rfloor * i \)
注意 n<k 时当前块的右端点可能超过 n !
#include<cstdio> #include<cstring> #include<algorithm> #define ll long long using namespace std; int n,k;ll ans; int main() { scanf("%d%d",&n,&k); int lm=min(n,k); for(int i=1,j,d;i<=lm;i=j+1) { d=k/i; j=min(k/d,n);//min!!! ans+=(ll)d*(i+j)*(j-i+1)>>1ll; } printf("%lld\n",(ll)n*k-ans); return 0; }
原文地址:https://www.cnblogs.com/Narh/p/10112042.html
时间: 2024-10-10 13:10:09