답안 #614579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
614579 2022-07-31T04:01:10 Z 1bin Strongbox (POI11_sej) C++14
100 / 100
798 ms 2648 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], sz;
vector<ll> d;
 
ll gcd(ll a, ll b){
    if(!b) return a;
    return gcd(b,  a % b);
}
 
int chk(ll& x){
    for(int i = 0; i < sz; i++)
        if(m[i] % 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);
    sort(m, m + k - 1);
    for(int i = 0; i < k - 1; i++) if(m[i] != m[i + 1]) m[sz++] = m[i];
    
    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;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 9 ms 320 KB Output is correct
4 Correct 13 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 73 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 312 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 90 ms 324 KB Output is correct
4 Correct 62 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 77 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 91 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 3 ms 212 KB Output is correct
3 Correct 64 ms 316 KB Output is correct
4 Correct 94 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 1088 KB Output is correct
2 Correct 25 ms 1080 KB Output is correct
3 Correct 318 ms 1316 KB Output is correct
4 Correct 796 ms 1856 KB Output is correct
5 Correct 209 ms 1456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 1804 KB Output is correct
2 Correct 59 ms 1824 KB Output is correct
3 Correct 138 ms 2068 KB Output is correct
4 Correct 663 ms 1784 KB Output is correct
5 Correct 265 ms 2224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 2196 KB Output is correct
2 Correct 86 ms 2264 KB Output is correct
3 Correct 351 ms 2524 KB Output is correct
4 Correct 741 ms 2524 KB Output is correct
5 Correct 268 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 2148 KB Output is correct
2 Correct 86 ms 2216 KB Output is correct
3 Correct 477 ms 2492 KB Output is correct
4 Correct 798 ms 2556 KB Output is correct
5 Correct 283 ms 2636 KB Output is correct