답안 #740479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
740479 2023-05-12T14:40:33 Z mzv Savrsen (COCI17_savrsen) C++17
120 / 120
1124 ms 78592 KB
#include <bits/stdc++.h>

#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

/* ------------------------ hi lol ------------------------ */

// author : mzv

ll l,r,ans=0;
vector<ll> sieve(10000001,0);

int main() {
	ccd
	cin >> l >> r;
	for (int i=1;i<=r;i++) {
		ll ks=i;
		while (ks+i<=r) {
			sieve[ks+i]+=i;
			ks+=i;
		}
	}
	for (int i=l;i<=r;i++) {
		ans+=abs(i-sieve[i]);
	}
	cout << ans << endl;
}

// gamungkin menggunakan teknik hitung manual karena bakal lama
// pake teknik sieve keknya karena cmn sieve yg cepet ngeluarin hsl pembagian utk size gede
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 78548 KB Output is correct
2 Correct 32 ms 78544 KB Output is correct
3 Correct 33 ms 78580 KB Output is correct
4 Correct 1055 ms 78540 KB Output is correct
5 Correct 1124 ms 78592 KB Output is correct
6 Correct 1077 ms 78536 KB Output is correct
7 Correct 956 ms 78520 KB Output is correct
8 Correct 237 ms 78540 KB Output is correct