QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#552329#7679. Master of Both IVJiangnan01WA 79ms43044kbC++172.1kb2024-09-07 22:03:242024-09-07 22:03:25

Judging History

你现在查看的是最新测评结果

  • [2024-09-07 22:03:25]
  • 评测
  • 测评结果:WA
  • 用时:79ms
  • 内存:43044kb
  • [2024-09-07 22:03:24]
  • 提交

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];//数的个数
vector<int> ps[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=31;i>=0;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(auto i:a)
    {
        for(auto x:ps[i])
        {
            if(mp[x]>=1 && (x != i))
            {
                if(add(x,i)==1)ra[i]++;
                con[i]+=mp[x];
            }
        }
    }
    int ans=0;
    //cout<<r<<"\n";
    ans+=ksm(2,n-r);
    for(auto x:a)
    {
        //cout<<x<<" : "<<con[x]<<" "<<ra[x]<<" " << mp[x]<<"\n";
        int t=con[x]-ra[x];
        ans+=ksm(2,t)*ksm(2,mp[x]-1)%p1;
        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;
    for(int i=1;i<=2e5;i++)
    {
        for(int j=i;j<=2e5;j+=i)
        {
            ps[j].push_back(i);
        }
    }
    while(T--){
        solve();
    }
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 68ms
memory: 42096kb

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: 79ms
memory: 43044kb

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
9
9
8
8
9
8
8
9
9
8
8
8
8
9
12
9
11
15
8
8
13
13
8
11
8
8
8
13
15
9
9
8
8
8
11
9
11
9
11
9
13
9
8
8
8
9
11
8
9
11
8
8
11
11
9
8
9
8
8
15
11
8
17
9
11
8
8
8
12
9
9
11
8
13
9
8
15
8
8
9
8
8
8
15
8
11
9
8
9
11
8
19
11
13
15
13
9
15
8
8
8
9
8
9
9
11
13
9
9
13
9
11
9
9
11
9
9
11
8
9
9
13
15
11
8
11
...

result:

wrong answer 11th numbers differ - expected: '13', found: '9'