Submission #202953

#TimeUsernameProblemLanguageResultExecution timeMemory
202953MKopchevStrongbox (POI11_sej)C++14
100 / 100
990 ms5752 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=3e5+42; int n; long long total; long long inp[nmax]; long long output,proper; vector<long long> to_test; void trial(long long num) { if(proper%num)return; for(int i=1;i<=n;i++) if(inp[i]%num==0)return; printf("%lld\n",total/num); exit(0); } int main() { scanf("%lld%i",&total,&n); for(int i=1;i<=n;i++)scanf("%lld",&inp[i]); proper=inp[n]; n--; for(int i=1;i<=n;i++)inp[i]=__gcd(inp[i],__gcd(proper,total)); set<long long> actual={}; for(int i=1;i<=n;i++)actual.insert(inp[i]); n=0; for(auto k:actual) { n++; inp[n]=k; } output=total; for(long long i=1;i*i<=total;i++) if(total%i==0) { to_test.push_back(i); to_test.push_back(total/i); } sort(to_test.begin(),to_test.end()); for(auto k:to_test) trial(k); return 0; }

Compilation message (stderr)

sej.cpp: In function 'int main()':
sej.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%i",&total,&n);
     ~~~~~^~~~~~~~~~~~~~~~~~~~
sej.cpp:22:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++)scanf("%lld",&inp[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...