Submission #332599

# Submission time Handle Problem Language Result Execution time Memory
332599 2020-12-02T22:45:57 Z thecodingwizard Strongbox (POI11_sej) C++11
0 / 100
1000 ms 19820 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define ii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define inf 1000000010

bool no[10000001];
bool notPrime[10000001];

int main() {
    cin.tie(0)->sync_with_stdio(0);

    ll n; int k; cin >> n >> k;
    if (k == 1) {
        cout << n << endl;
        return 0;
    }
    ll bad[k-1]; F0R(i, k-1) cin >> bad[i];
    ll good; cin >> good;

    ll gcd = __gcd(n, good); assert(gcd <= 1e7);
    for (int i = 2; i <= gcd; i++) {
        if (!notPrime[i]) {
            for (int j = i+i; j <= gcd; j += i) {
                notPrime[j] = true;
            }
        }
    }

    for (int i = 2; i <= gcd; i++) {
        if (notPrime[i]) continue;
        bool isBad = false;
        F0R(j, k-1) if (bad[j] % i == 0) isBad = true;
        if (isBad) {
            for (int j = i; j <= gcd; j += i) {
                no[j] = true;
            }
        }
    }

    for (int i = 2; i <= gcd; i++) {
        if (gcd % i == 0 && !no[i]) {
            cout << n/i << endl;
            return 0;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1516 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 581 ms 19820 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 5 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 492 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1047 ms 5356 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 2908 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 4460 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 5228 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 5228 KB Execution killed with signal 6 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -