#include <bits/stdc++.h>
using namespace std;
using tint = long long;
using ld = long double;
#define forsn(i, s, n) for(int i = s; i < int(n); i++)
#define forn(i, n) forsn(i, 0, n)
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair
#define DBG(x) cerr << #x << " = " << x << endl;
const int MOD = 1e9+7;
const int MX = 1e5+5;
const tint INF = 1e18;
const int inf = 2e9;
const ld PI = acos(ld(-1));
void NACHO(string name = "moop"){
ios_base::sync_with_stdio(0); cin.tie(0);
//freopen((name+".in").c_str(), "r", stdin);
//freopen((name+".out").c_str(), "w", stdout);
}
struct pt{
int x, y;
bool operator<(const pt &o)const{
if(x == o.x) return y < o.y;
return x < o.x;
}
};
int main(){
NACHO();
int a, b;
cin >> a >> b;
vi sum (b+1, 0);
forsn(i, 1, b+1){
for(int j = i+i; j <= b; j+=i){
sum[j]+=i;
}
}
int tot = 0;
forsn(i, a, b+1){
tot+=abs(i-sum[i]);
}
cout << tot << endl;
//pensa que si vas por todas las rectas horizontales de arriba p abajo,
//podes considerar a todos los puntos en se recta con los puntos en los extremos.
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Incorrect |
2 ms |
748 KB |
Output isn't correct |
4 |
Incorrect |
1291 ms |
39652 KB |
Output isn't correct |
5 |
Incorrect |
1289 ms |
39652 KB |
Output isn't correct |
6 |
Incorrect |
1296 ms |
39652 KB |
Output isn't correct |
7 |
Incorrect |
1184 ms |
36452 KB |
Output isn't correct |
8 |
Incorrect |
228 ms |
10348 KB |
Output isn't correct |