天天看点

A New Function(除法分块)

​​传送门​​

A New Function(除法分块)

题意:

思路:

#include<bits/stdc++.h>
using namespace std;
#define ll long long



int main()
{
  int t;
  cin>>t;
  for(int i = 1; i <= t; i++)
  {
    ll ans = 0;
    ll n;
    cin>>n;
    ll l = 1;
    while(l < n)
    {
      ans += (l+n/(n/l))*(n/(n/l)-l+1)/2*(n/l-1);
      l = n/(n/l)+1;
    }
    if(n == 0)cout<<"Case "<<i<<": "<<0<<endl;
    else
    cout<<"Case "<<i<<": "<<ans-n+1<<endl;
    
  }
  
}      

继续阅读