QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#785703#2809. PresentsnpmrnhlolCompile Error//C++171.1kb2024-11-26 18:52:012024-11-26 18:52:01

Judging History

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

  • [2024-11-26 18:52:01]
  • 评测
  • [2024-11-26 18:52:01]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 40;
//const int step = 1e6;
ll x;
int gcd[N + 1][N + 1];
void make_gcd_closed(ll& x){
    for(int i = N;i >= 1;i--){
        for(int j = N;j >= 1;j--){
            if((x>>i&1) && (x>>j&1)){
                x|=(1ll<<gcd[i][j]);
            }
        }
    }
}
void get_next_set(ll& x){
    for(int i = 1;i <= N;i++){
        if(!(x>>i&1)){
            x|=(1ll<<i);
            break;
        }
        x^=(1ll<<i);
    }
    make_gcd_closed(x);
}
void dbg(ll x){
    for(int i = 1;i <= N;i++){
        if(x>>i&1){
            cout<<i<<' ';
        }
    }
    cout<<'\n';
}
void solve(){
    int x;
    cin>>x;
    ll nr = 0;
    for(int i = 0;i < x;i++){
        get_next_set(nr);
    }
    cout<<__builtin_popcount(nr)<<' ';
    dbg(nr);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= N;j++){
            gcd[i][j] = __gcd(i, j);
        }
    }

    int t;
    cin>>t;
    while(t--)solve();

    return 0;
}

详细

answer.code: In function ‘void make_gcd_closed(ll&)’:
answer.code:12:26: error: reference to ‘gcd’ is ambiguous
   12 |                 x|=(1ll<<gcd[i][j]);
      |                          ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:58,
                 from answer.code:1:
/usr/include/c++/13/numeric:164:5: note: candidates are: ‘template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)’
  164 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
answer.code:7:5: note:                 ‘int gcd [41][41]’
    7 | int gcd[N + 1][N + 1];
      |     ^~~
answer.code: In function ‘int main()’:
answer.code:50:13: error: reference to ‘gcd’ is ambiguous
   50 |             gcd[i][j] = __gcd(i, j);
      |             ^~~
/usr/include/c++/13/numeric:164:5: note: candidates are: ‘template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)’
  164 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
answer.code:7:5: note:                 ‘int gcd [41][41]’
    7 | int gcd[N + 1][N + 1];
      |     ^~~