商最多有sqrt(n)个。
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #define int long long 6 using namespace std; 7 int n,k; 8 signed main() 9 { 10 scanf("%lld%lld",&n,&k); 11 int ans=n*k;if(n>k)n=k; 12 int l,r,j; 13 for(int i=1;i<=n;i=r+1) 14 { 15 int y=k/i;r=k/y; 16 if(r>n)r=n; 17 ans-=y*(r-i+1)*(i+r)/2; 18 } 19 printf("%lld ",ans); 20 return 0; 21 }