제출 #1104920

#제출 시각아이디문제언어결과실행 시간메모리
1104920dzhoz0Savrsen (COCI17_savrsen)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; 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; }

컴파일 시 표준 에러 (stderr) 메시지

savrsen.cpp:3:11: error: 'MAXN' was not declared in this scope
    3 | int sieve[MAXN + 5];
      |           ^~~~
savrsen.cpp: In function 'void init()':
savrsen.cpp:6:12: error: 'sieve' was not declared in this scope
    6 |     memset(sieve, 0, sizeof(sieve));
      |            ^~~~~
savrsen.cpp:7:31: error: 'MAXN' was not declared in this scope
    7 |     for(long long i = 2; i <= MAXN; i++) {
      |                               ^~~~
savrsen.cpp: In function 'long long int f(int)':
savrsen.cpp:19:17: error: 'sieve' was not declared in this scope
   19 |         int d = sieve[n];
      |                 ^~~~~
savrsen.cpp: In function 'int main()':
savrsen.cpp:36:17: error: 'l' was not declared in this scope
   36 |     for(int x = l; x <= r; x++)
      |                 ^
savrsen.cpp:36:25: error: 'r' was not declared in this scope
   36 |     for(int x = l; x <= r; x++)
      |                         ^