답안 #493685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493685 2021-12-12T15:09:20 Z SangTin Brunhilda’s Birthday (BOI13_brunhilda) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define name "TRACKS"
#define endl '\n'
#define ednl endl
#define long long long
#define memset(a, x) memset(a, (x), sizeof(a));
#define inoutf freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define IN(a, b, c) (a <= b && b <= c)

template<typename T, typename U> inline bool amin(T &x, U y) { if(y >= x) return 0; x = y; return 1;}
template<typename T, typename U> inline bool amax(T &x, U y) { if(x >= y) return 0; x = y; return 1;}
template<typename T> inline void read(T& x){
    bool Neg = false;
    char c;
    for (c = getchar(); c < '0' | c > '9'; c = getchar())
        if (c == '-') Neg = !Neg;
    x = c - '0';
    for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    if (Neg) x = -x;
}

const int M = 1e5 + 83, N = 1e7 + 83;
long No = 1;
int p[M], spf[N], GCD[N], m;
bool isPrime[N], select[N];
vector <int> Prime;

void Sieve(){
    memset(isPrime, 1);
    memset(spf, 0x3f);
    for (int i = 2; i < N; ++i){
        if (isPrime[i]){
            Prime.push_back(i);
            spf[i] = i;
        }
        for (int j = 0; j < Prime.size() && 1ll * i * Prime[j] < N && Prime[j] <= spf[i]; ++j){
            isPrime[i * Prime[j]] = 0;
            spf[i * Prime[j]] = Prime[j];
        }
    }
}

int cal(int n){
    if (n < p[m]) return 1;
    int cur = m, tmp = n;
    while (cur && tmp % p[cur] == 0){
        while (tmp % p[cur] == 0) tmp /= p[cur];
        --cur;
    }
    return (cur ? (1 + cal(n - n % p[cur])) : -1);
}

int Solve(){
    Sieve();
    memset(select, 0);
    int q; cin >> m >> q;
    for (int i = 1; i <= m; ++i){
        cin >> p[i];
        select[p[i]] = 1;
        if (No != -1) No *= p[i];
        if (No > 1e7) No = -1;
    }
    sort(p + 1, p + m + 1);
    while (q--){
        int n; cin >> n;
        int tmp = cal(n);
        if (tmp == -1) cout << "oo\n";
        else cout << tmp << endl;
    }

    return 0;
}

int main(){
    fastio;

    int t = 1;
//    cin >> t;
    while (t--){
        Solve();
    }

    return 0;
}

Compilation message

brunhilda.cpp:30:26: error: 'bool select [10000083]' redeclared as different kind of entity
   30 | bool isPrime[N], select[N];
      |                          ^
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:394,
                 from /usr/include/c++/10/bits/std_abs.h:38,
                 from /usr/include/c++/10/cmath:47,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from brunhilda.cpp:1:
/usr/include/x86_64-linux-gnu/sys/select.h:101:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  101 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
brunhilda.cpp: In function 'void Sieve()':
brunhilda.cpp:41:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (int j = 0; j < Prime.size() && 1ll * i * Prime[j] < N && Prime[j] <= spf[i]; ++j){
      |                         ~~^~~~~~~~~~~~~~
brunhilda.cpp: In function 'int Solve()':
brunhilda.cpp:60:12: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
    9 | #define memset(a, x) memset(a, (x), sizeof(a));
      |                                           ~~~
......
   60 |     memset(select, 0);
brunhilda.cpp:9:44: note: in definition of macro 'memset'
    9 | #define memset(a, x) memset(a, (x), sizeof(a));
      |                                            ^
brunhilda.cpp:60:12: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'void*' [-fpermissive]
   60 |     memset(select, 0);
      |            ^~~~~~
      |            |
      |            int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)
brunhilda.cpp:9:29: note: in definition of macro 'memset'
    9 | #define memset(a, x) memset(a, (x), sizeof(a));
      |                             ^
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from brunhilda.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
brunhilda.cpp:64:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   64 |         select[p[i]] = 1;
      |                    ^
brunhilda.cpp:64:22: error: assignment of read-only location '*(select + ((sizetype)p[i]))'
   64 |         select[p[i]] = 1;
      |         ~~~~~~~~~~~~~^~~