답안 #332612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332612 2020-12-03T01:32:38 Z thecodingwizard Strongbox (POI11_sej) C++11
28 / 100
372 ms 1204 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

vector<ll> primes;
ll ans = 1e18;
set<ll> illegalNumbers;

void handleNumber(ll n, bool updAns) {
    illegalNumbers.insert(n);
    if (updAns) ans = min(ans, n);
    for (ll p : primes) {
        if (n % p == 0 && illegalNumbers.count(n/p) == 0) {
            handleNumber(n/p, updAns);
        }
    }
}

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

    ll n; int k; cin >> n >> k;
    ll origN = n;
    if (k == 1) {
        cout << n << endl;
        return 0;
    }

    for (ll i = 2; i*i <= n; i++) {
        if (n%i == 0) {
            primes.pb(i);
            while (n%i == 0) n /= i;
        }
    }

    F0R(i, k) {
        ll x; cin >> x;
        handleNumber(__gcd(origN, x), i==k-1);
    }

    cout << origN/ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 3 ms 492 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 10 ms 364 KB Output is correct
4 Correct 6 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Incorrect 19 ms 1004 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 102 ms 392 KB Output is correct
4 Correct 14 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 364 KB Output is correct
2 Correct 17 ms 1132 KB Output is correct
3 Correct 69 ms 492 KB Output is correct
4 Incorrect 15 ms 1004 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 71 ms 364 KB Output is correct
4 Correct 16 ms 1004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 364 KB Output is correct
2 Correct 44 ms 492 KB Output is correct
3 Incorrect 55 ms 1004 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 364 KB Output is correct
2 Correct 300 ms 1132 KB Output is correct
3 Incorrect 68 ms 748 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 364 KB Output is correct
2 Correct 372 ms 1204 KB Output is correct
3 Correct 93 ms 1132 KB Output is correct
4 Correct 106 ms 1132 KB Output is correct
5 Incorrect 89 ms 1004 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -