QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#558160#858. GCD vs. XORrotcar07Compile Error//C++14560b2024-09-11 14:35:162024-09-11 14:35:16

Judging History

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

  • [2024-09-11 14:35:16]
  • 评测
  • [2024-09-11 14:35:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e6+5;
vector<int> d[maxn>>1];
inline void solve(){
    int n;cin>>n;
    unordered_map<int,int> mp;
    for(int i=1,x;i<=n;i++) cin>>x,mp[x]++;
    long long ans=0;
    for(auto [x,y]:mp){
        for(auto z:d[x]){
            int w=(x^z);
            if(mp.count(w)&&gcd(w,x)==z) ans+=y*1ll*mp[w];
        }
    }
    cout<<ans/2<<'\n';
}
int main(){
    for(int i=1;i<=1e6;i++)
    for(int j=i+i;j<=1e6;j+=i) d[j].push_back(i);
    int T;cin>>T;
    while(T--) solve();
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:10:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   10 |     for(auto [x,y]:mp){
      |              ^
answer.code:13:29: error: ‘gcd’ was not declared in this scope
   13 |             if(mp.count(w)&&gcd(w,x)==z) ans+=y*1ll*mp[w];
      |                             ^~~