#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> da, db;
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){
da.emplace_back(i);
db.emplace_back(x / i);
}
for(ll& x : da) if(chk(x)) {
cout << n / x; return 0;
}
for(int i = db.size() - 1; i >= 0; i--)
if(chk(db[i])) {
cout << n / db[i]; return 0;
}
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 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
9 ms |
212 KB |
Output is correct |
4 |
Correct |
11 ms |
420 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 |
256 KB |
Output is correct |
4 |
Correct |
77 ms |
520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
91 ms |
316 KB |
Output is correct |
4 |
Correct |
62 ms |
516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
68 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
80 ms |
528 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 |
91 ms |
516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
3 ms |
340 KB |
Output is correct |
3 |
Correct |
60 ms |
212 KB |
Output is correct |
4 |
Correct |
93 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
94 ms |
1104 KB |
Output is correct |
2 |
Correct |
27 ms |
1076 KB |
Output is correct |
3 |
Correct |
309 ms |
1276 KB |
Output is correct |
4 |
Correct |
827 ms |
1712 KB |
Output is correct |
5 |
Correct |
216 ms |
1440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
67 ms |
1996 KB |
Output is correct |
2 |
Correct |
70 ms |
1868 KB |
Output is correct |
3 |
Correct |
149 ms |
1924 KB |
Output is correct |
4 |
Correct |
668 ms |
1844 KB |
Output is correct |
5 |
Correct |
255 ms |
2148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
2272 KB |
Output is correct |
2 |
Correct |
89 ms |
2264 KB |
Output is correct |
3 |
Correct |
345 ms |
2532 KB |
Output is correct |
4 |
Correct |
769 ms |
2524 KB |
Output is correct |
5 |
Correct |
299 ms |
2580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
2276 KB |
Output is correct |
2 |
Correct |
89 ms |
2204 KB |
Output is correct |
3 |
Correct |
482 ms |
2460 KB |
Output is correct |
4 |
Correct |
801 ms |
2556 KB |
Output is correct |
5 |
Correct |
291 ms |
2688 KB |
Output is correct |