Submission #1104921

# Submission time Handle Problem Language Result Execution time Memory
1104921 2024-10-24T17:41:33 Z dzhoz0 Savrsen (COCI17_savrsen) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e7;
int sieve[MAXN + 5];

void init() {
    memset(sieve, 0, sizeof(sieve));
    for(long long i = 2; i <= MAXN; i++) {
        if(sieve[i] != 0) continue;
        sieve[i] = i;
        for(long long j = i * i; j <= MAXN; j += i) {
            sieve[j] = (sieve[j] == 0 ? i : sieve[j]);
        }
    }
}
long long f(int n) {
    long long res = 1;
    
    while(n > 1) {
        int d = sieve[n];
        int e = 1;
        while(n % d == 0) e++, n /= d;
        long long sum = 0, pw = 1;
        while(e--) {
            sum += pw;
            pw *= d;
        }
        res *= sum;
    }
    return res;
}

int main()
{
    init();
    long long res = 0;
    for(int x = l; x <= r; x++)
        res += abs(x - (f(x) - x));
    cout << res << '\n';
    return 0;
}

Compilation message

savrsen.cpp: In function 'int main()':
savrsen.cpp:38:17: error: 'l' was not declared in this scope
   38 |     for(int x = l; x <= r; x++)
      |                 ^
savrsen.cpp:38:25: error: 'r' was not declared in this scope
   38 |     for(int x = l; x <= r; x++)
      |                         ^