一个数论分块 一个等差数列
数论分开的板子一直记得是个错的 妈蛋
记得加mod 因为 等差数列是递减的 我一直以为是越界 int128都上了
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+ 7;
#define int long long
typedef long long ll;
typedef __int128 LL;
ll quick(ll a, ll b){
ll ans = 1;
while(b){
if(b&1){
ans = ans*a%mod;
}
b >>= 1;
a = a*a%mod;
}
return ans;
}
signed main()
{
int n;
cin >> n;
LL ans = 0;
int inv = quick(2, mod - 2);
for(int i = 1; i <= n ;){
LL len = n/(n/i);
LL len1 = (len - i + 1);
len1%= mod;
ans = (ans + (len1*(n%i)%mod + len1*(len1 - 1)%mod*(-1*(n/i))%mod*inv%mod)%mod)%mod;
i = len + 1;
}
ll ans1 = ans;
cout << ans1 << endl;
}