Submission #97996

# Submission time Handle Problem Language Result Execution time Memory
97996 2019-02-19T17:34:51 Z brcode Strongbox (POI11_sej) C++14
21 / 100
37 ms 2552 KB
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int ans;
int total;
const int MAXN = 250005;
int arr[MAXN];
bool common(int x){
    for(int i=1;i<=total;i++){
        if(arr[i]%x == 0){
            return false;
        }
       
    }
     return true;
}
int main() {
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        cin>>arr[i];
    }
    for(int i=1;i<=k;i++){
        arr[i] = __gcd(n,arr[i]);
    }
    sort(arr+1,arr+k);
    for(int i=1;i<k;i++){
        if(arr[i]!=arr[i-1]){
            total++;
            arr[total] = arr[i];
        }
    }
  
    for(int 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;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 360 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 2364 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 2412 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 2364 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 25 ms 2408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 2472 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 37 ms 2420 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 2368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 2552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 2396 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 2484 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -