Submission #97327

#TimeUsernameProblemLanguageResultExecution timeMemory
97327tmwilliamlin168Strongbox (POI11_sej)C++14
100 / 100
697 ms4984 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n, m, ans=1e18, p[12], n2; int k, ps; set<ll> v; void dfs(ll u, bool ua=0) { if(ua) ans=min(u, ans); v.insert(u); for(int i=0; i<ps; ++i) if(u%p[i]==0&&v.find(u/p[i])==v.end()) dfs(u/p[i], ua); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; n2=n; for(ll i=2; i*i<n; ++i) { if(n%i) continue; p[ps++]=i; while(n%i==0) n/=i; } if(n>0) p[ps++]=n; for(int i=0; i<k; ++i) cin >> m, dfs(__gcd(m, n2), i==k-1); cout << n2/ans; }
#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...