QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#306774#5542. Doubled GCDAestivateCompile Error//C++20946b2024-01-17 10:29:132024-01-17 10:29:14

Judging History

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

  • [2024-01-17 10:29:14]
  • 评测
  • [2024-01-17 10:29:13]
  • 提交

answer

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

#define ing long long 
#define F first 
#define S second 
#define pb push_back 

int d(int t1){
    int c1=0,c2=0;
    while(t1%2==0) t1/=2,c1++;
    return c1;
}

int gcd(int t1,int t2){
    if(t2==0) return t1;
    return gcd(t2,t1%t2);
}

void solve(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now;
    for(int i=1;i<=n;i++) cin>>a[i],now.push({d(a[i]),a[i]});

    // cout<<gcd(2000000000,2000000000)*2ll<<"\n";
    while(now.size()>1){
        auto t1=now.top();now.pop();
        auto t2=now.top();now.pop();
        // cerr<<t1.S<<" "<<t2.S<<"\n";
        int v=gcd(t1.S,t2.S)*2ll;
        // cerr<<v<<"\n";
        int dd=d(v);
        now.push({dd,v});
    }
    cout<<now.top().S<<"\n";
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:22:5: error: ‘cin’ was not declared in this scope
   22 |     cin>>n;
      |     ^~~
answer.code:23:5: error: ‘vector’ was not declared in this scope
   23 |     vector<int>a(n+1);
      |     ^~~~~~
answer.code:23:12: error: expected primary-expression before ‘int’
   23 |     vector<int>a(n+1);
      |            ^~~
answer.code:24:20: error: ‘pair’ was not declared in this scope
   24 |     priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now;
      |                    ^~~~
answer.code:24:5: error: ‘priority_queue’ was not declared in this scope
   24 |     priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now;
      |     ^~~~~~~~~~~~~~
answer.code:24:25: error: expected primary-expression before ‘int’
   24 |     priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now;
      |                         ^~~
answer.code:25:32: error: ‘a’ was not declared in this scope
   25 |     for(int i=1;i<=n;i++) cin>>a[i],now.push({d(a[i]),a[i]});
      |                                ^
answer.code:25:37: error: ‘now’ was not declared in this scope
   25 |     for(int i=1;i<=n;i++) cin>>a[i],now.push({d(a[i]),a[i]});
      |                                     ^~~
answer.code:28:11: error: ‘now’ was not declared in this scope
   28 |     while(now.size()>1){
      |           ^~~
answer.code:37:5: error: ‘cout’ was not declared in this scope
   37 |     cout<<now.top().S<<"\n";
      |     ^~~~
answer.code:37:11: error: ‘now’ was not declared in this scope
   37 |     cout<<now.top().S<<"\n";
      |           ^~~
answer.code: In function ‘int main()’:
answer.code:41:5: error: ‘ios’ has not been declared
   41 |     ios::sync_with_stdio(0);cin.tie(0);
      |     ^~~
answer.code:41:29: error: ‘cin’ was not declared in this scope
   41 |     ios::sync_with_stdio(0);cin.tie(0);
      |                             ^~~