#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, ans;
vector<ll> d;
ll gcd(ll a, ll b){
if(!b) return a;
return gcd(b, a % b);
}
set<ll> s;
void p(ll x){
s.emplace(x);
for(ll& y : d)
if(x % y == 0 && s.find(x / y) == s.end()) p(x / y);
return;
}
void find(ll x){
ans = min(ans, x);
s.emplace(x);
for(ll& y : d)
if(x % y == 0 && s.find(x / y) == s.end()) find(x / y);
return;
}
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);
x = n;
for(ll i = 2; i * i <= n; i++)
if(x % i == 0){
while(x % i == 0) x /= i;
d.emplace_back(i);
}
if(x > 1) d.emplace_back(x);
for(int i = 0; i < k - 1; i++) p(m[i]);
ans = n;
find(m[k - 1]);
cout << n / ans;
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 |
1 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 |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
212 KB |
Output is correct |
2 |
Correct |
6 ms |
340 KB |
Output is correct |
3 |
Correct |
9 ms |
324 KB |
Output is correct |
4 |
Correct |
10 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
212 KB |
Output is correct |
2 |
Correct |
48 ms |
956 KB |
Output is correct |
3 |
Correct |
89 ms |
304 KB |
Output is correct |
4 |
Correct |
47 ms |
968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
212 KB |
Output is correct |
2 |
Correct |
39 ms |
316 KB |
Output is correct |
3 |
Correct |
86 ms |
312 KB |
Output is correct |
4 |
Correct |
37 ms |
868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
332 KB |
Output is correct |
2 |
Correct |
58 ms |
972 KB |
Output is correct |
3 |
Correct |
87 ms |
212 KB |
Output is correct |
4 |
Correct |
47 ms |
972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
212 KB |
Output is correct |
2 |
Correct |
46 ms |
328 KB |
Output is correct |
3 |
Correct |
58 ms |
312 KB |
Output is correct |
4 |
Correct |
64 ms |
1084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
340 KB |
Output is correct |
2 |
Correct |
47 ms |
212 KB |
Output is correct |
3 |
Correct |
84 ms |
212 KB |
Output is correct |
4 |
Correct |
57 ms |
1088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
85 ms |
980 KB |
Output is correct |
2 |
Correct |
82 ms |
1220 KB |
Output is correct |
3 |
Correct |
90 ms |
1728 KB |
Output is correct |
4 |
Correct |
110 ms |
2188 KB |
Output is correct |
5 |
Correct |
90 ms |
1840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
1880 KB |
Output is correct |
2 |
Correct |
295 ms |
2768 KB |
Output is correct |
3 |
Correct |
94 ms |
2356 KB |
Output is correct |
4 |
Correct |
106 ms |
3920 KB |
Output is correct |
5 |
Correct |
118 ms |
4684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
93 ms |
2264 KB |
Output is correct |
2 |
Correct |
342 ms |
3036 KB |
Output is correct |
3 |
Correct |
127 ms |
2916 KB |
Output is correct |
4 |
Correct |
144 ms |
5704 KB |
Output is correct |
5 |
Correct |
139 ms |
5624 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
2264 KB |
Output is correct |
2 |
Correct |
346 ms |
3072 KB |
Output is correct |
3 |
Correct |
132 ms |
2904 KB |
Output is correct |
4 |
Correct |
139 ms |
2956 KB |
Output is correct |
5 |
Correct |
125 ms |
2976 KB |
Output is correct |