Submission #614607

# Submission time Handle Problem Language Result Execution time Memory
614607 2022-07-31T04:08:16 Z 1bin Strongbox (POI11_sej) C++14
100 / 100
823 ms 4476 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], ans;
vector<ll> 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){
            if(chk(i)) {
                ans = n / i; break;
            }
            else if(chk(x / i)) ans = n / (x / i);
        }
    cout << ans;
    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 1 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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 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 1 ms 212 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 212 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 9 ms 212 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 1 ms 212 KB Output is correct
4 Correct 29 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 352 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 90 ms 340 KB Output is correct
4 Correct 61 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 68 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 1 ms 340 KB Output is correct
4 Correct 27 ms 348 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 65 ms 340 KB Output is correct
4 Correct 37 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 2204 KB Output is correct
2 Correct 28 ms 2200 KB Output is correct
3 Correct 476 ms 2272 KB Output is correct
4 Correct 823 ms 3596 KB Output is correct
5 Correct 409 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 4000 KB Output is correct
2 Correct 65 ms 4048 KB Output is correct
3 Correct 247 ms 4064 KB Output is correct
4 Correct 699 ms 3640 KB Output is correct
5 Correct 510 ms 4040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 4460 KB Output is correct
2 Correct 92 ms 4384 KB Output is correct
3 Correct 605 ms 4352 KB Output is correct
4 Correct 814 ms 4424 KB Output is correct
5 Correct 514 ms 4424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 4424 KB Output is correct
2 Correct 94 ms 4392 KB Output is correct
3 Correct 513 ms 4476 KB Output is correct
4 Correct 815 ms 4400 KB Output is correct
5 Correct 570 ms 4376 KB Output is correct