Submission #197384

#TimeUsernameProblemLanguageResultExecution timeMemory
197384stefdascaStrongbox (POI11_sej)C++14
100 / 100
556 ms4792 KiB
#include<bits/stdc++.h> #define god dimasi5eks #pragma GCC optimize("O3") #define fi first #define se second #define pb push_back #define pf push_front #define mod 1000000007 #define dancila 3.14159265359 #define eps 1e-9 // #define fisier 1 using namespace std; typedef long long ll; ll n, k, m, ans = (1LL<<60); ll cmmdc(ll a, ll b) { ll c; while(b) { c = a%b; a = b; b = c; } return a; } vector<ll> primes; set<ll> s; void dfs(ll nod, bool chk) { if(chk == 1) ans = min(ans, nod); s.insert(nod); for(int i = 0; i < primes.size(); ++i) if(nod % primes[i] == 0 && s.find(nod / primes[i]) == s.end()) dfs(nod/primes[i], chk); } int main() { #ifdef fisier ifstream f("input.in"); ofstream g("output.out"); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; if(k == 1) { cout << n; return 0; } ll nn = n; for(ll i = 2; i * i <= n; ++i) if(n % i == 0) { primes.pb(i); while(n % i == 0) n /= i; } if(n > 1) primes.pb(n); for(int i = 1; i <= k; ++i) { ll p; cin >> p; dfs(cmmdc(p, nn), (i == k)); } cout << nn/ans; return 0; }

Compilation message (stderr)

sej.cpp: In function 'void dfs(ll, bool)':
sej.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < primes.size(); ++i)
                    ~~^~~~~~~~~~~~~~~
#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...