BZOJ 1257[CQOI2007]余数之和sum | 数论
题目:
http://www.lydsy.com/JudgeOnline/problem.php?id=1257
题解:
不知道咋做的
#include<cstdio> #include<algorithm> typedef long long ll; ll ans,n,k; int main() { scanf("%lld%lld",&n,&k); if (n>k) { ans=(n-k)*k,n=k; } ll r; for (ll i=1;i<=n;i=r+1) { ll t=k/i;r=k/t; if (r>=n) r=n; ans+=(r-i+1ll)*k-(r-i+1ll)*(i+r)/2*t; } printf("%lld\n",ans); return 0; }