QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#696488 | #7679. Master of Both IV | chikel | WA | 19ms | 5676kb | C++20 | 1.3kb | 2024-10-31 22:53:40 | 2024-10-31 22:53:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i128 = __int128_t;
#define int long long
#define endl '\n'
#define ar array<int,2>
#define fi first
#define se second
random_device rd;
mt19937 mt(rd());
const int md = 998244353;
const int N = 5e5+10;
const int inf= 1e18;
const double eps=1e-10;
int p[N],cnt,a[N];
int ksm(int base, int power, int p) {
int result = 1;
while (power > 0) {
if (power & 1)result = result * base % p;
base = base * base % p ;
power >>= 1;
}
return result % p;
}
void insert(int x) {
for(int i=60; i>=0; i--) {
if((x>>i)&1) {
if(!p[i]) {
p[i]=x;
cnt++;
return ;
} else
x^=p[i];
}
}
}
void solve() {
int ans=0;
cnt=0;
int n;
cin >> n;
for(int i=60; i>=0; i--)
p[i]=0;
for(int i=1; i<=n; i++)
a[i]=0;
for(int i=1; i<=n; i++) {
int k;
cin >> k;
insert(k);
a[k]++;
}
for(int i=1; i<=n; i++) {
int o=0;
if(a[i]) {
for(int j=1; j*j<=i; j++) {
if(j!=i&&i%j==0) {
o+=a[j];
if(j*j!=i&&i/j!=i)
o+=a[i/j];
}
}
ans=(ans+ksm(2,a[i]-1,md)*ksm(2,o-1,md)%md)%md;
}
}
ans=(ans+ksm(2,n-cnt,md))%md;
cout << ans-1 << endl;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5604kb
input:
2 3 1 2 3 5 3 3 5 1 1
output:
4 11
result:
ok 2 number(s): "4 11"
Test #2:
score: -100
Wrong Answer
time: 19ms
memory: 5676kb
input:
40000 5 4 2 5 5 5 5 5 5 5 5 4 5 1 4 4 4 2 5 2 5 2 4 1 5 3 2 4 5 3 5 1 5 5 3 4 5 5 5 5 4 3 5 4 3 3 5 1 5 4 5 5 2 1 5 2 5 4 2 5 5 3 4 3 4 3 5 5 3 5 1 3 5 5 1 2 4 4 5 4 2 5 1 5 5 5 4 2 5 4 5 5 2 5 2 4 5 1 4 5 4 5 5 4 2 3 2 3 5 1 4 1 3 5 5 1 1 2 1 5 5 5 2 5 1 3 5 3 1 2 5 3 5 5 5 1 1 5 5 2 2 2 1 3 5 3 1 ...
output:
9 16 13 11 8 8 9 8 9 9 13 8 10 9 8 9 12 9 11 15 8 8 17 13 9 11 8 8 8 13 15 11 9 9 9 8 11 11 11 13 15 9 17 9 9 9 8 13 11 10 9 11 8 8 11 15 11 10 9 9 9 19 11 9 17 9 15 8 10 10 12 11 9 11 10 17 11 8 19 8 9 9 8 9 8 15 8 11 13 9 11 13 9 19 13 17 19 17 13 15 8 8 8 9 8 9 13 15 17 9 9 17 11 11 9 9 11 13 9 1...
result:
wrong answer 3rd numbers differ - expected: '9', found: '13'