Submission #97997

#TimeUsernameProblemLanguageResultExecution timeMemory
97997brcodeStrongbox (POI11_sej)C++14
70 / 100
1078 ms5976 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...