Submission #614562

# Submission time Handle Problem Language Result Execution time Memory
614562 2022-07-31T03:57:23 Z 1bin Strongbox (POI11_sej) C++14
100 / 100
815 ms 4800 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 1 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 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 332 KB Output is correct
3 Correct 9 ms 212 KB Output is correct
4 Correct 12 ms 460 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 1 ms 212 KB Output is correct
4 Correct 87 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 348 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 97 ms 340 KB Output is correct
4 Correct 63 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 83 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 92 ms 584 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 65 ms 340 KB Output is correct
4 Correct 97 ms 580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2160 KB Output is correct
2 Correct 28 ms 2300 KB Output is correct
3 Correct 323 ms 2232 KB Output is correct
4 Correct 797 ms 3596 KB Output is correct
5 Correct 215 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 3992 KB Output is correct
2 Correct 62 ms 4120 KB Output is correct
3 Correct 137 ms 4024 KB Output is correct
4 Correct 673 ms 3692 KB Output is correct
5 Correct 262 ms 4040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 4472 KB Output is correct
2 Correct 95 ms 4428 KB Output is correct
3 Correct 337 ms 4392 KB Output is correct
4 Correct 747 ms 4464 KB Output is correct
5 Correct 265 ms 4616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 4456 KB Output is correct
2 Correct 90 ms 4432 KB Output is correct
3 Correct 479 ms 4456 KB Output is correct
4 Correct 815 ms 4632 KB Output is correct
5 Correct 298 ms 4800 KB Output is correct