Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- const ll nmax=1e9+7;
- ll int_sqrt (ll x) {
- ll ans = 0;
- for (ll k = 1LL << 30; k != 0; k /= 2) {
- if ((ans + k) * (ans + k) <= x) {
- ans += k;
- }
- }
- return ans;
- }
- int main()
- {
- ll n;
- cin>>n;
- ll sq=int_sqrt(n);
- ll ans=0;
- for (ll i=1; i*i<=n; i++){
- ans+=((i*(n/i))%nmax+(((n/i)*(1+n/i))/2)%nmax)%nmax;
- }
- ans=(ans+nmax-(((((sq%nmax)*((sq+1)%nmax))/2)%nmax)*sq)%nmax)%nmax;
- cout<<ans<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement