QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673866 | #7679. Master of Both IV | XiaoMo247 | WA | 107ms | 36748kb | C++20 | 1.8kb | 2024-10-25 11:12:43 | 2024-10-25 11:12:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 5;
const ll MOD = 998244353;
ll Tex, n, a[MAXN], d[35], zero;
vector<ll> b[MAXN];
map<ll, ll> cnt;
void init(){
for(int i = 0; i <= 32; i ++){
d[i] = 0;
}
}
bool insert(ll x){
for(int i = 32; i >= 0; i --){
if(!((x >> i) & 1)) continue;
if(d[i]) x ^= d[i];
else{
d[i] = x;
break;
}
}
if(!x){
zero ++;
return 0;
}
return 1;
}
ll fastPow(ll a, ll b){
ll ret = 1;
while(b){
if(b & 1) ret = a * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return ret;
}
ll calc(ll x){
init();
ll ret = 0;
for(auto it : b[x]){
if(cnt[it]){
if(insert(it)){
ret += cnt[it] - 1;
}
else{
ret += cnt[it];
}
}
}
// cout << " " << ret << "\n";
return fastPow(2, ret);
}
ll M(ll x){
return (x % MOD + MOD) % MOD;
}
void AC(){
cin >> n;
cnt.clear();
init();
zero = 0;
for(int i = 1; i <= n; i ++){
cin >> a[i];
insert(a[i]);
}
ll ans = 0;
ans = M(fastPow(2, zero) - 1);
sort(a + 1, a + n + 1);
for(int i = 1; i <= n; i ++){
ans = M(ans + calc(a[i]));
// cout << calc(a[i]) << '\n';
cnt[a[i]] ++;
}
cout << ans << '\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
for(int i = 1; i <= MAXN - 5; i ++){
for(int j = i; j <= MAXN - 5; j += i){
b[j].push_back(i);
}
}
cin >> Tex;
while(Tex --) AC();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 107ms
memory: 36748kb
input:
2 3 1 2 3 5 3 3 5 1 1
output:
6 29
result:
wrong answer 1st numbers differ - expected: '4', found: '6'