-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1082.cc
71 lines (61 loc) · 1.27 KB
/
1082.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <bits/stdc++.h>
using namespace std;
int _add(int a, int b, int mod){
a += b;
if(a >= mod) a -= mod;
return a;
}
int _sub(int a, int b, int mod){
a -= b;
if(a < 0) a += mod;
return a;
}
int _mult(int a, int b, int mod){
return (1LL * a * b) % mod;
}
int _power(int a, int b, int mod){
if(!b) return 1;
int x = _power(a, b >> 1, mod);
x = _mult(x, x, mod);
if(b&1) x = _mult(x, a, mod);
return x;
}
int _inverse(int x, int mod){
return _power(x, mod - 2, mod);
}
int _div(int a, int b, int mod){
return _mult(a, _inverse(b, mod), mod);
}
constexpr int mod = 1000000007;
constexpr int limit = 1000000;
int F(long long x, int mod) {
long long v1 = x;
long long v2 = x + 1;
if (v1%2 == 0)
v1 /= 2;
else
v2 /= 2;
v1 %= mod;
v2 %= mod;
return _mult(v1, v2, mod);
}
int sum(long long l, long long r, int mod) {
return _sub(F(r, mod), F(l - 1, mod), mod);
}
int main() {
long long n;
cin >> n;
long long ans = 0;
long long last_num = n;
for (int c = 1; last_num >= limit; c++) {
long long v1 = n / c;
long long v2 = n / (c + 1) + 1;
ans = _add(ans, _mult(c, sum(v2, v1, mod), mod), mod);
last_num = v2 - 1;
}
for (int i = 1; i <= (int)(last_num); i++) {
ans = _add(ans, _mult(i, ((n/i) % mod), mod), mod);
}
cout << ans << "\n";
return 0;
}