Submission #318469

# Submission time Handle Problem Language Result Execution time Memory
318469 2020-11-02T04:12:38 Z ignaciocanta Savrsen (COCI17_savrsen) C++14
120 / 120
1463 ms 78692 KB
#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<tint>;
#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;
		}
	}
	tint 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 Correct 2 ms 1132 KB Output is correct
4 Correct 1448 ms 78692 KB Output is correct
5 Correct 1448 ms 78564 KB Output is correct
6 Correct 1463 ms 78564 KB Output is correct
7 Correct 1328 ms 72516 KB Output is correct
8 Correct 300 ms 20324 KB Output is correct