QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#552302#7679. Master of Both IVJiangnan01WA 130ms43244kbC++172.1kb2024-09-07 21:51:462024-09-07 21:51:47

Judging History

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

  • [2024-09-07 21:51:47]
  • 评测
  • 测评结果:WA
  • 用时:130ms
  • 内存:43244kb
  • [2024-09-07 21:51:46]
  • 提交

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=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(auto i:a)
    {
        for(auto x:ps[i])
        {
            if(mp[x]>=1 && (x != i || mp[i]>=2))
            {
                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]<<"\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;
    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;
}


詳細信息

Test #1:

score: 100
Accepted
time: 114ms
memory: 42308kb

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: 130ms
memory: 43244kb

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

result:

wrong answer 2nd numbers differ - expected: '16', found: '24'