Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define fixed(n) fixed << setprecision(n)
- #define ceil(n, m) (((n) + (m) - 1) / (m))
- #define add_mod(a, b, m) (((a % m) + (b % m)) % m)
- #define sub_mod(a, b, m) (((a % m) - (b % m) + m) % m)
- #define mul_mod(a, b, m) (((a % m) * (b % m)) % m)
- #define all(vec) vec.begin(), vec.end()
- #define rall(vec) vec.rbegin(), vec.rend()
- #define sz(x) int(x.size())
- #define debug(x) cout << #x << ": " << (x) << "\n";
- #define fi first
- #define se second
- #define ll long long
- #define ull unsigned long long
- #define EPS 1e-9
- constexpr int INF = 1 << 30, Mod = 1e9 + 7;
- constexpr ll LINF = 1LL << 62;
- #define PI acos(-1)
- template < typename T = int > using Pair = pair < T, T >;
- vector < string > RET = {"NO", "YES"};
- template < typename T = int > istream& operator >> (istream &in, vector < T > &v) {
- for (auto &x : v) in >> x;
- return in;
- }
- template < typename T = int > ostream& operator << (ostream &out, const vector < T > &v) {
- for (const T &x : v) out << x << ' ';
- return out;
- }
- ll divisorSum(ll num){
- ll sum = 0;
- for (ll i = 1; i <= sqrt(num); i++) {
- ll t1 = i * (num / i - i + 1);
- ll t2 = (((num / i) * (num / i + 1)) / 2) - ((i * (i + 1)) / 2);
- sum += t1 + t2;
- }
- return sum;
- }
- void Solve(){
- ll l, r;
- cin >> l >> r;
- cout << divisorSum(r) - divisorSum(l - 1) << "\n";
- }
- int main(){
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- int test_cases = 1;
- // cin >> test_cases;
- for(int tc = 1; tc <= test_cases; tc++){
- // cout << "Case #" << tc << ": ";
- Solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement