Submission #614536

# Submission time Handle Problem Language Result Execution time Memory
614536 2022-07-31T03:46:19 Z 1bin Strongbox (POI11_sej) C++14
100 / 100
834 ms 7272 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 3e5 + 5;
ll n, x, k, m[NMAX];
vector<ll> d, v;

ll gcd(ll a, ll b){
    if(!b) return a;
    return gcd(b,  a % b);
}

int chk(ll x){
    for(ll y : v)
        if(y % x == 0) return 0;
    return 1;
}

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> k;
    for(int i = 0; i < k; i++) cin >> m[i], m[i] = gcd(m[i], n);
    for(int i = 0; i < k - 1; i++) v.emplace_back(m[i]);
    sort(all(v)); v.erase(unique(all(v)), v.end());
    
    x = m[k - 1];
    for(ll i = 1; i * i <= x; i++)
        if(x % i == 0){
            d.emplace_back(i);
            d.emplace_back(x / i);
        }
    sort(all(d));
    for(ll x : d) if(chk(x)) {
        cout << n / x; break;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 9 ms 320 KB Output is correct
4 Correct 12 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 73 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 88 ms 340 KB Output is correct
4 Correct 62 ms 556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 340 KB Output is correct
2 Correct 2 ms 276 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 83 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 89 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 61 ms 340 KB Output is correct
4 Correct 95 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 2176 KB Output is correct
2 Correct 28 ms 2252 KB Output is correct
3 Correct 328 ms 2260 KB Output is correct
4 Correct 834 ms 5200 KB Output is correct
5 Correct 229 ms 3360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 3988 KB Output is correct
2 Correct 67 ms 4040 KB Output is correct
3 Correct 159 ms 4040 KB Output is correct
4 Correct 705 ms 5356 KB Output is correct
5 Correct 288 ms 6036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 4380 KB Output is correct
2 Correct 101 ms 4404 KB Output is correct
3 Correct 376 ms 4332 KB Output is correct
4 Correct 828 ms 7148 KB Output is correct
5 Correct 300 ms 7216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 4424 KB Output is correct
2 Correct 119 ms 4432 KB Output is correct
3 Correct 517 ms 4380 KB Output is correct
4 Correct 827 ms 7272 KB Output is correct
5 Correct 304 ms 7200 KB Output is correct