QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#552280 | #7678. The Game | Jiangnan01 | WA | 66ms | 57744kb | C++17 | 2.0kb | 2024-09-07 21:40:42 | 2024-09-07 21:40:42 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MAXN = 2e5+10;
const int p1=998244353;
int p[MAXN][32];
int ra[MAXN],con[MAXN];//记录秩,因子个数
int mp[MAXN];//数的个数
set<int> a;
int r=0;
int ksm(int x,int y)
{
int ans=1;
while(y>0)
{
if(y&1)ans=ans*x%p1;
x=x*x%p1;
y>>=1;
}
return ans;
}
int add(int x,int k)
{
for(int i=0;i<=31;i++)
{
if((x>>i) && p[k][i]==0)
{
p[k][i]=x;
return 1;
}
else
{
x^=p[k][i];
}
}
return 0;
}
void solve()
{
int n;
cin>>n;
r=0;
a.clear();
for(int i=0;i<=n;i++)
{
mp[i]=0;
for(int j=0;j<32;j++)p[i][j]=0;
ra[i]=0;
con[i]=0;
}
for(int i=1;i<=n;i++)
{
int k;
cin>>k;
a.insert(k);
if(add(k,0)==1)r++;
mp[k]++;
}
for(int i=1;i<=2e5;i++)
{
if(mp[i]!=0)
{
for(int j=i;j<=2e5;j+=i)
{
if(add(i,j)==1 && (i!=j || mp[i]>1))ra[j]++;
con[j]+=mp[i];
}
}
}
int ans=0;
//cout<<r<<"\n";
ans+=ksm(2,n-r);
for(auto x:a)
{
//cout<<x<<" : "<<con[x]<<" "<<ra[x]<<"\n";
int t=con[x]-ra[x];
if(mp[x]==1)t-=1;
ans+=ksm(2,t);
ans%=p1;
}
cout<<(ans-1+p1)%p1<<"\n";
}
signed main()
{
//freopen("E:\work tool\code document\data\input.in", "r", stdin);
//freopen("E:\work tool\code document\data\output.out", "w", stdout);
ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0); //关闭同步 如果使用 则不要使用<cstdio>
// cout << fixed << setprecision(10);
int T=1;
cin>>T;
while(T--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 66ms
memory: 57744kb
input:
6 5 3 1 2 2 3 3 2 3 4 4 2 1 2 2 4 2 4 5 2 2 3 3 4 4 5 5 6 1 1 1 1 1 1 1 4 4 2 1 1 1 2 2 2 4 1 1 1 1 1 2
output:
12 7 8 7 3 8260
result:
wrong answer Integer 12 violates the range [-1, 5] (test case 1)