QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75472#5465. Maximum GCDtute7627AC ✓15ms3840kbC++177.4kb2023-02-05 12:13:222023-02-05 12:13:25

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-05 12:13:25]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:3840kb
  • [2023-02-05 12:13:22]
  • 提交

answer

//#define _GLIBCXX_DEBUG

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;


#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using QP = priority_queue<T,vector<T>,greater<T>>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T1,typename T2,typename T3>void anss(T1 x,T2 y,T3 z){ans(x!=y,x,z);};  
template<typename T>void debug(const T &v,ll h,ll w,string sv=" "){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout<<sv<<v[i][j];cout<<endl;}};
template<typename T>void debug(const T &v,ll n,string sv=" "){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout<<sv<<v[i];cout<<endl;};
template<typename T>void debug(const vector<T>&v){debug(v,v.size());}
template<typename T>void debug(const vector<vector<T>>&v){for(auto &vv:v)debug(vv,vv.size());}
template<typename T>void debug(stack<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(queue<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(deque<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop_front();}cout<<endl;}
template<typename T>void debug(PQ<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(QP<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(const set<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T>void debug(const multiset<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T,size_t size>void debug(const array<T, size> &a){for(auto z:a)cout<<z<<" ";cout<<endl;}
template<typename T,typename V>void debug(const map<T,V>&v){for(auto z:v)cout<<"["<<z.first<<"]="<<z.second<<",";cout<<endl;}
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << "(" << p.first << "," << p.second << ")";}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){os<<"[";for(auto &z:v)os << z << ",";os<<"]"; return os;}
template<typename T>void rearrange(vector<int>&ord, vector<T>&v){
  auto tmp = v;
  for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<int>&ord,Head&& head, Tail&&... tail){
  rearrange(ord, head);
  rearrange(ord, tail...);
}
template<typename T> vector<int> ascend(const vector<T>&v){
  vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
  sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],i)<make_pair(v[j],j);});
  return ord;
}
template<typename T> vector<int> descend(const vector<T>&v){
  vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
  sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],-i)>make_pair(v[j],-j);});
  return ord;
}
template<typename T> vector<T> inv_perm(const vector<T>&ord){
  vector<T>inv(ord.size());
  for(int i=0;i<ord.size();i++)inv[ord[i]] = i;
  return inv;
}
ll FLOOR(ll n,ll div){assert(div>0);return n>=0?n/div:(n-div+1)/div;}
ll CEIL(ll n,ll div){assert(div>0);return n>=0?(n+div-1)/div:n/div;}
ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
ll modulo(ll n,ll d){return (n%d+d)%d;};
template<typename T>T min(const vector<T>&v){return *min_element(v.begin(),v.end());}
template<typename T>T max(const vector<T>&v){return *max_element(v.begin(),v.end());}
template<typename T>T acc(const vector<T>&v){return accumulate(v.begin(),v.end(),T(0));};
template<typename T>T reverse(const T &v){return T(v.rbegin(),v.rend());};
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};
template<typename T>T poll(queue<T> &q){auto ret=q.front();q.pop();return ret;};
template<typename T>T poll(priority_queue<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(QP<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(stack<T> &s){auto ret=s.top();s.pop();return ret;};
ll MULT(ll x,ll y){if(LLONG_MAX/x<=y)return LLONG_MAX;return x*y;}
ll POW2(ll x, ll k){ll ret=1,mul=x;while(k){if(mul==LLONG_MAX)return LLONG_MAX;if(k&1)ret=MULT(ret,mul);mul=MULT(mul,mul);k>>=1;}return ret;}
ll POW(ll x, ll k){ll ret=1;for(int i=0;i<k;i++){if(LLONG_MAX/x<=ret)return LLONG_MAX;ret*=x;}return ret;}
template< typename T = int >
struct edge {
  int to;
  T cost;
  int id;
  edge():id(-1){};
  edge(int to, T cost = 1, int id = -1):to(to), cost(cost), id(id){}
  operator int() const { return to; }
};

template<typename T>
using Graph = vector<vector<edge<T>>>;
template<typename T>
Graph<T>revgraph(const Graph<T> &g){
  Graph<T>ret(g.size());
  for(int i=0;i<g.size();i++){
    for(auto e:g[i]){
      int to = e.to;
      e.to = i;
      ret[to].push_back(e);
    }
  }
  return ret;
}
template<typename T>
Graph<T> readGraph(int n,int m,int indexed=1,bool directed=false,bool weighted=false){
  Graph<T> ret(n);
  for(int es = 0; es < m; es++){
    int u,v;
    T w=1;
    cin>>u>>v;u-=indexed,v-=indexed;
    if(weighted)cin>>w;
    ret[u].emplace_back(v,w,es);
    if(!directed)ret[v].emplace_back(u,w,es);
  }
  return ret;
}
template<typename T>
Graph<T> readParent(int n,int indexed=1,bool directed=true){
  Graph<T>ret(n);
  for(int i=1;i<n;i++){
    int p;cin>>p;
    p-=indexed;
    ret[p].emplace_back(i);
    if(!directed)ret[i].emplace_back(p);
  }
  return ret;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  sort(ALL(a));
  bool x=true;
  rep(i,0,n){
    if(a[i]%a[0]!=0&&a[0]*2>a[i])x=false;
  }
  if(x)cout<<a[0]<<endl;
  else cout<<a[0]/2<<endl;
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3364kb

input:

3
3 10 7

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 15ms
memory: 3800kb

input:

100000
154183567 764881828 59831034 828193326 391773598 487722171 451196811 245718514 750259573 762740115 821999084 28801227 218042831 918898632 881477122 891010192 55732830 509020430 594855913 455478382 456571462 705949609 471532655 550005603 861581472 984465652 883456918 463213251 626620153 371990...

output:

3772

result:

ok 1 number(s): "3772"

Test #3:

score: 0
Accepted
time: 11ms
memory: 3796kb

input:

100000
80 88 53 77 74 63 57 71 75 74 27 14 38 23 24 75 33 89 81 33 100 56 53 77 55 54 63 80 100 15 70 24 100 65 95 22 34 12 31 30 83 20 68 87 23 53 53 55 72 13 57 94 27 94 93 81 96 57 11 81 18 53 34 67 77 65 38 45 45 33 66 47 56 61 60 55 13 61 60 83 24 68 88 50 59 44 27 99 22 82 16 96 62 60 98 48 78...

output:

5

result:

ok 1 number(s): "5"

Test #4:

score: 0
Accepted
time: 15ms
memory: 3840kb

input:

100000
999999598 999999894 999999159 999999706 999999201 999999362 999999889 999999054 999999169 999999662 999999967 999999278 999999478 999999996 999999011 999999630 999999240 999999446 999999989 999999526 999999874 999999704 999999555 999999997 999999622 999999847 999999791 999999729 999999697 999...

output:

499999500

result:

ok 1 number(s): "499999500"

Test #5:

score: 0
Accepted
time: 10ms
memory: 3808kb

input:

100000
2339018 1749754 3376731 9508803 1986463 3632005 6226628 1462120 8271360 8846247 8379452 2960858 1687623 3059513 9805949 8592853 4763971 6382780 1552229 8402035 9055846 6039035 1412389 9103272 3160554 4293404 4986833 7422294 1031511 3281256 7401944 2250268 1895990 1052625 6425782 1547099 61500...

output:

500018

result:

ok 1 number(s): "500018"

Test #6:

score: 0
Accepted
time: 2ms
memory: 3404kb

input:

1
4360

output:

4360

result:

ok 1 number(s): "4360"

Test #7:

score: 0
Accepted
time: 2ms
memory: 3484kb

input:

2
709714 1581844

output:

709714

result:

ok 1 number(s): "709714"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3488kb

input:

10
546260421 852755840 481560053 275469550 908149678 453897265 988292618 110888697 95642218 528793626

output:

47821109

result:

ok 1 number(s): "47821109"

Test #9:

score: 0
Accepted
time: 2ms
memory: 3372kb

input:

100
110842178 108800257 72759981 167863159 126815647 147998087 156926565 92960393 163090092 142384022 164406682 156939726 136887138 165468770 134596858 223474322 97825730 140041433 214450935 101221271 164581907 111738193 95079147 118597457 15464369 146274776 13173492 208648228 55473866 144762527 190...

output:

3632469

result:

ok 1 number(s): "3632469"

Test #10:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

1000
220299256 818992931 393579095 566632684 301307837 267738513 432133522 193826234 510693893 303832615 31651720 331802168 452517197 204717553 819141338 118957844 891384645 105969610 582852865 423577261 683962479 267714012 276703072 169705634 816472207 991537051 604437115 743242595 803544449 690388...

output:

1052882

result:

ok 1 number(s): "1052882"

Test #11:

score: 0
Accepted
time: 5ms
memory: 3400kb

input:

23333
496045500 525432320 143815245 112875917 993696102 977190752 198396742 353003244 268023040 903330201 68717203 439179007 130025015 978235984 305201913 281833236 675440265 104325916 187917906 448922032 905415627 378289162 145741324 156545800 93769892 228957212 593555881 708502918 663131407 521415...

output:

3596

result:

ok 1 number(s): "3596"

Test #12:

score: 0
Accepted
time: 2ms
memory: 3376kb

input:

100
3 2 5 4 3 3 3 3 4 3 1 2 3 2 3 1 4 1 5 2 5 3 3 5 2 3 5 4 3 4 1 5 5 2 2 1 3 5 1 3 5 2 2 1 4 3 1 3 5 1 1 3 5 5 5 4 5 5 1 5 3 5 4 3 5 4 1 1 2 1 2 5 1 2 2 2 3 5 5 5 4 2 3 2 1 2 3 5 2 2 2 2 5 3 5 4 2 5 3 4

output:

1

result:

ok 1 number(s): "1"

Test #13:

score: 0
Accepted
time: 2ms
memory: 3400kb

input:

1000
92 69 30 28 54 75 47 8 47 84 19 37 20 33 30 70 30 2 98 52 29 23 90 16 98 29 78 97 86 8 27 9 31 80 45 48 83 50 59 60 99 42 55 14 70 78 27 47 12 6 95 40 35 98 84 44 34 24 47 57 39 91 100 4 41 16 58 76 20 39 16 65 72 54 51 37 60 11 36 64 64 24 92 62 97 38 94 39 40 23 58 25 39 72 35 8 33 68 73 90 4...

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: 0
Accepted
time: 2ms
memory: 3408kb

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #15:

score: 0
Accepted
time: 2ms
memory: 3508kb

input:

1
1000000000

output:

1000000000

result:

ok 1 number(s): "1000000000"

Test #16:

score: 0
Accepted
time: 2ms
memory: 3412kb

input:

2
1000000000 1000000000

output:

1000000000

result:

ok 1 number(s): "1000000000"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3432kb

input:

2
1 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #18:

score: 0
Accepted
time: 2ms
memory: 3444kb

input:

30
1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912

output:

1

result:

ok 1 number(s): "1"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3380kb

input:

20
1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912

output:

1024

result:

ok 1 number(s): "1024"

Test #20:

score: 0
Accepted
time: 9ms
memory: 3808kb

input:

100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1

result:

ok 1 number(s): "1"

Test #21:

score: 0
Accepted
time: 12ms
memory: 3840kb

input:

100000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

1000000000

result:

ok 1 number(s): "1000000000"