QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#558160 | #858. GCD vs. XOR | rotcar07 | Compile Error | / | / | C++14 | 560b | 2024-09-11 14:35:16 | 2024-09-11 14:35:16 |
Judging History
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();
}
Details
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]; | ^~~