#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
long long ans;
long long total;
const long long MAXN = 250005;
long long arr[MAXN];
bool common(long long x){
for(long long i=1;i<=total;i++){
if(arr[i]%x == 0){
return false;
}
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n,k;
cin>>n>>k;
for(long long i=1;i<=k;i++){
cin>>arr[i];
}
for(long long i=1;i<=k;i++){
arr[i] = __gcd(n,arr[i]);
}
sort(arr+1,arr+k);
for(long long i=1;i<k;i++){
if(arr[i]!=arr[i-1]){
total++;
arr[total] = arr[i];
}
}
for(long long i=1;i<=sqrt(arr[k]);i++){
if(arr[k]%i == 0){
if(common(i)){
ans = n/i;
break;
}
if(common(arr[k]/i)){
ans = (n/arr[k]*i);
}
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
9 ms |
400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
17 ms |
512 KB |
Output is correct |
4 |
Correct |
31 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
66 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
129 ms |
508 KB |
Output is correct |
4 |
Correct |
113 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
400 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
130 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
356 KB |
Output is correct |
4 |
Correct |
54 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
100 ms |
408 KB |
Output is correct |
4 |
Correct |
85 ms |
408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
149 ms |
1408 KB |
Output is correct |
2 |
Correct |
70 ms |
1400 KB |
Output is correct |
3 |
Correct |
945 ms |
1416 KB |
Output is correct |
4 |
Execution timed out |
1064 ms |
3064 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
129 ms |
2248 KB |
Output is correct |
2 |
Correct |
124 ms |
2232 KB |
Output is correct |
3 |
Correct |
487 ms |
2168 KB |
Output is correct |
4 |
Execution timed out |
1046 ms |
1792 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
154 ms |
2600 KB |
Output is correct |
2 |
Correct |
169 ms |
2552 KB |
Output is correct |
3 |
Execution timed out |
1020 ms |
2464 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
148 ms |
2524 KB |
Output is correct |
2 |
Correct |
197 ms |
2652 KB |
Output is correct |
3 |
Execution timed out |
1073 ms |
2552 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |