#include <iostream>/*
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
*/
//add more if needed-------------------------------------------------//
#define fio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define rfopen(s) freopen(s, "r", stdin)
#define wfopen(s) freopen(s, "w", stdout)
#define len(a) int(a.size())
#define forw(i, a, b, s) for(int i = a; i < b; i += s)
#define revs(i, a, b, s) for(int i = a; i > b; i -= s)
#define PB push_back
#define EB emplace_back
#define ever ;;
#define FS first
#define SC second
#define PI acos(-1.0)
#define resarr(a) memset(a, 0, sizeof a);
#define LBound lower_bound
#define UBound upper_bound
//bit
#define CNTBIT(x) __builtin_popcount(x)
#define ODDBIT(x) __builtin_parity(x)
#define MASK(i) (1<<(i))
#define BIT(x, i) x&MASK(i)
#define SUBSET(big, small) (((big)&(small))==(small))
using namespace std;
namespace io {
const int SIZE = (1 << 20) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
inline void flush() { fwrite (obuf, 1, oS - obuf, stdout); oS = obuf; } // print the remaining part
inline void putc(char x) { *oS++ = x; if (oS == oT) flush (); } // putchar
template<typename A> inline bool read (A &x) {
for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1; else if (c == EOF) return 0;
for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
return 1;
}
inline bool read(char &x) {
while((x = gc()) == ' ' || x == '\n' || x == '\r'); return x != EOF;
}
inline bool read(string& x) {
while ((c = gc()) == '\n' || c == ' '|| c == '\r'); if (c == EOF) return 0; x.clear();
while (!(c == '\n' || c == ' ' || c == '\r' || c == EOF)) x.push_back(c), c = gc(); return 1;
}
template<typename A,typename ...B>
inline bool read(A &x, B &...y){ return read(x) + read(y...); }
template<typename A> inline bool write(A x) {
if (!x) putc('0'); if (x < 0) putc ('-'), x = -x;
while (x) qu[++qr] = x % 10 + '0', x /= 10;
while (qr) putc(qu[qr--]);
return 0;
}
inline bool write(char x) { putc(x); return 0; }
inline bool write(const char *x){ while (*x){ putc(*x); ++x; } return 0; }
inline bool write(char *x){ while (*x){ putc(*x); ++x; } return 0; }
template<typename A,typename ...B>
inline bool write(A x,B ...y){ return write(x) || write(y...); }
//no need to call flush at the end manually!
struct Flusher_ {~Flusher_(){ flush(); }} io_flusher_;
} using io::read; using io::putc; using io::write;/*
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<ll, ll> pll;
typedef pair<pii, int> pii_i;
typedef pair<int, pii> pi_ii;
typedef pair<int, pll> pi_ll;
typedef pair<float, int> pfi;
typedef pair<ull, pii> pll_ii;
typedef pair<float, pii> pfii;
int add(int a, int b, int mod){
return (a % mod + b % mod) % mod;
}
int sub(int a, int b, int mod){
return (a % mod + mod - b % mod) % mod;
}
int mul(ll a, ll b, int mod){
return (a % mod * b % mod) % mod;
}*/
int Abs(int n) {
return (n ^ (n >> 31)) - (n >> 31);
}/*
int max(int a, int b) { return b & ((a - b) >> 31) | a & (~(a - b) >> 31); }
int min(int a, int b) { return a & ((a - b) >> 31) | b & (~(a - b) >> 31); }
bool isSameSign(int x, int y) {
return (x ^ y) >= 0;
}
void swap(int &a, int &b) { a ^= b ^= a ^= b; }*/
//add more if needed-------------------------------------------------//
const int INF = 1e9 + 7;
const float fINF = 340282346638528859811704183484516925439.0000000000000000;
const int N = 1e7 + 7; ///replace N with the given limit
const int MOD = 1e9 + 7; ///replace this with mod value
long long int sdiv[N];
void init(int n){
for (int i = 1; i <= n; i++){
for (int j = i; j <= n; j+=i){
sdiv[j] += i;
}
}
}
int main(){
///preprocessing
#ifndef ONLINE_JUDGE
//rfopen("test.inp");
//wfopen("test.out");
#endif // ONLINE_JUDGE
fio;
///code
int l, r;
read(l, r);
init(r);
long long int ans = 0;
for (int i = l; i <= r; i++){
ans += Abs(i * 2 - sdiv[i]);
}
write(ans);
}
/**
Must read note before coding ANYTHING!!!:
- Plan things out before coding (variable names, function names and such) and stay organized
- Put things that have to be use multiple times into a function
- Simplify shit as much as possible (still have to be readable)
- Do something instead of nothing
- Use note
- DO NOT STICK TO ONE APPROACH!!!
Stuff you should look for while debugging:
- int overflow
- array bound
- special cases (n == 1), (n == 0)?
Read these before doing anything, you"ll thanks me later >^<
~(Ruriko, from the Past)~
**/
Compilation message
savrsen.cpp: In function 'bool io::read(A&)':
savrsen.cpp:57:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
57 | for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
| ^~~
savrsen.cpp:57:76: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
57 | for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;
| ^
savrsen.cpp: In function 'bool io::read(char&)':
savrsen.cpp:61:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
61 | while((x = gc()) == ' ' || x == '\n' || x == '\r'); return x != EOF;
| ^~~~~
savrsen.cpp:61:61: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
61 | while((x = gc()) == ' ' || x == '\n' || x == '\r'); return x != EOF;
| ^~~~~~
savrsen.cpp: In function 'bool io::read(std::string&)':
savrsen.cpp:64:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
64 | while ((c = gc()) == '\n' || c == ' '|| c == '\r'); if (c == EOF) return 0; x.clear();
| ^~~~~
savrsen.cpp:64:61: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
64 | while ((c = gc()) == '\n' || c == ' '|| c == '\r'); if (c == EOF) return 0; x.clear();
| ^~
savrsen.cpp:65:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
65 | while (!(c == '\n' || c == ' ' || c == '\r' || c == EOF)) x.push_back(c), c = gc(); return 1;
| ^~~~~
savrsen.cpp:65:93: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
65 | while (!(c == '\n' || c == ' ' || c == '\r' || c == EOF)) x.push_back(c), c = gc(); return 1;
| ^~~~~~
savrsen.cpp: In function 'bool io::write(A)':
savrsen.cpp:70:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
70 | if (!x) putc('0'); if (x < 0) putc ('-'), x = -x;
| ^~
savrsen.cpp:70:28: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
70 | if (!x) putc('0'); if (x < 0) putc ('-'), x = -x;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
1100 KB |
Output is correct |
4 |
Correct |
1452 ms |
78580 KB |
Output is correct |
5 |
Correct |
1583 ms |
78580 KB |
Output is correct |
6 |
Correct |
1572 ms |
78576 KB |
Output is correct |
7 |
Correct |
1429 ms |
72432 KB |
Output is correct |
8 |
Correct |
326 ms |
20224 KB |
Output is correct |