[题解](数学)BZOJ_1257_余数求和
来源:https://blog.csdn.net/loi_dqs/article/details/50522975
并不知道为什么是sqrt(n)的段数......书上写的看不懂......
但是这个思路好难想(打表大法好
不开longlong一时爽,一会提交火葬场!!!
OI千万条,longlong第一条
乘法不longlong,提交两行泪
#include<cstring> #include<cstdio> #include<iostream> #include<algorithm> #define ll long long using namespace std; ll n,k,ans; int main(){ scanf("%lld%lld",&n,&k); ans=(ll)n*k; if(n>k)n=k; ll l,r,w; for(ll i=1;i<=n;i=r+1){ w=k/i; l=i; r=k/w; if(r>n)r=n; ans-=(r-l+1)*w*(l+r)/2; } printf("%lld",ans); }