# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091890 | plagia | Savrsen (COCI17_savrsen) | C++14 | 252 ms | 39768 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdlib>
#include <iostream>
const int MM = 1e7 + 10;
int tab[MM]{};
void fill_tab() {
for (int i = 1; i < MM; i++) {
tab[i] = 0;
}
for (int i = 1; i * i <= MM; i++) {
for (int j = i * 2; j < MM; j += i) {
tab[j] += i;
}
}
}
int calculate_imperfection(const int &n) {
return std::abs(n - tab[n]);
}
int main() {
std::ios_base::sync_with_stdio(0);
fill_tab();
int a, b;
std::cin >> a >> b;
unsigned long long sum = 0;
for (int i = a; i <= b; i++) {
sum += calculate_imperfection(i);
}
std::cout << sum << std::endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |