# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1091885 | plagia | Savrsen (COCI17_savrsen) | C++14 | 21 ms | 8468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdlib>
#include <iostream>
const int MM = 1e6 + 10;
int tab[MM]{};
void fill_tab() {
for (int i = 1; i < MM; i++) {
tab[i] = 0; // Initialize all values to zero
}
for (int i = 1; i < MM; i++) { // i is a potential divisor
for (int j = 2 * i; j < MM; j += i) { // add i to all multiples of i, excluding itself
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... |