Input
Output
Input
3 4
Output
4
HINT
原式
=n*m-n除以i向下取整
用数论分块做就可以了
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; long long ans; long long n,m; int main(){ scanf("%lld%lld",&n,&m); for(register long long i=1,last=0;i<=m;i=last+1) { long long p=n/i; if(p) { last=min(n/p,m); }else{ last=m; } ans=(ans+(((last-i+1)%mod*((n%i)%mod+(n%last)%mod))%mod*500000004))%mod; } printf("%lld",ans); return 0; }
来源:https://www.cnblogs.com/2017gdgzoi44/p/11348536.html