#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() {
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 |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
256 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 |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
256 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 |
22 ms |
256 KB |
Output is correct |
4 |
Correct |
24 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
64 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
368 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
125 ms |
476 KB |
Output is correct |
4 |
Correct |
110 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
126 ms |
484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
53 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
87 ms |
508 KB |
Output is correct |
4 |
Correct |
85 ms |
420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
183 ms |
2164 KB |
Output is correct |
2 |
Correct |
96 ms |
2168 KB |
Output is correct |
3 |
Execution timed out |
1067 ms |
2168 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
200 ms |
4524 KB |
Output is correct |
2 |
Correct |
211 ms |
4828 KB |
Output is correct |
3 |
Correct |
674 ms |
3912 KB |
Output is correct |
4 |
Execution timed out |
1078 ms |
3164 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
295 ms |
5200 KB |
Output is correct |
2 |
Correct |
295 ms |
5880 KB |
Output is correct |
3 |
Execution timed out |
1076 ms |
4728 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
263 ms |
4868 KB |
Output is correct |
2 |
Correct |
279 ms |
5976 KB |
Output is correct |
3 |
Execution timed out |
1063 ms |
4984 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |