标签:efault main 图片 info div tps img long lse
题目分析:
\(G\left ( n,m\right ) = \sum_{i=1}^{n} k mod i = \sum_{i=1}^{n}k-\left \lfloor k/i\right \rfloor*i = n*k-\sum_{i=1}^{n}\left \lfloor k/i\right \rfloor*i\)
AC_Code:
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 typedef long long ll; 5 using namespace std; 6 7 ll n,k; 8 int main() 9 { 10 scanf("%lld%lld",&n,&k); 11 ll ans=n*k; 12 13 for(ll l=1,r;l<=n;l=r+1){ 14 if( k/l!=0 ) r=min(k/(k/l),n); 15 else r=n; 16 ans -= (k/l)*(r-l+1)*(l+r)/2; 17 } 18 19 printf("%lld\n",ans); 20 return 0; 21 }
标签:efault main 图片 info div tps img long lse
原文地址:https://www.cnblogs.com/wsy107316/p/12650577.html