QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#333447 | #7679. Master of Both IV | xuzhihaodedie | WA | 52ms | 6668kb | C++20 | 1.2kb | 2024-02-19 22:16:32 | 2024-02-19 22:16:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define lson 2*p
#define rson 2*p+1
//#define endl "\n"
#define x first
#define y second
#define lowbit(x) x&-x
const int N=2e5+10;
const int mod=998244353;
int d[25],a[N],p[N];
void insert(int x) {
for(int i=20;i>=0;i--) {
if(!(x>>i&1)) continue;
if(d[i]) x^=d[i];
else {
d[i]=x;
return ;
}
}
}
void solve() {
int n;
cin>>n;
memset(d,0,sizeof d);
vector<int> cnt(n+10,0),res(n+10,1);
for(int i=1;i<=n;i++) {
cin>>a[i];
insert(a[i]);
cnt[a[i]]++;
}
int r=0;
int ans=0;
for(int i=20;i>=0;i--) if(d[i]) r++;
ans+=p[n-r]-1;
for(int i=1;i<=n;i++) {
int num=cnt[i];
if(num<2) continue;
for(int j=i+i;j<=n;j+=i) {
res[j]=res[j]*p[num-1]%mod;
}
num--;
if(num<2) continue;
res[i]=res[i]*p[num-1]%mod;
}
for(int i=1;i<=n;i++) {
if(!cnt[i]) continue;
ans=(ans+cnt[i]*res[i]%mod)%mod;
}
cout<<ans<<endl;
}
signed main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int T=1;
cin>>T;
p[0]=1;
for(int i=1;i<=2e5;i++) p[i]=p[i-1]*2%mod;
while(T--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5360kb
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: 52ms
memory: 6668kb
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:
11 24 11 9 8 8 11 8 8 9 15 8 8 8 8 9 12 9 11 17 8 8 21 15 8 11 8 8 8 15 15 9 9 8 8 8 11 9 11 15 15 11 21 11 8 8 8 15 11 8 11 11 8 8 11 15 9 8 9 8 8 17 11 8 21 9 15 8 8 8 12 9 11 11 8 13 9 8 17 8 8 11 8 8 8 15 8 11 15 8 9 11 8 21 11 13 21 21 15 17 8 8 8 9 8 11 15 15 21 11 9 21 9 11 11 11 11 11 9 11 8...
result:
wrong answer 1st numbers differ - expected: '9', found: '11'