QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555978#7679. Master of Both IVwdwWA 18ms3612kbC++202.3kb2024-09-10 13:20:452024-09-10 13:20:46

Judging History

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

  • [2024-09-10 13:20:46]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3612kb
  • [2024-09-10 13:20:45]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double db;
#define int long long
const int N = 2e5 + 10;
const double eps = 1e-10;
#define ull unsigned long long
#define endl '\n'
using i64 = int64_t;
const int mod =998244353;
int ans = 0;
int ksm(int a, int b) {
    int ans = 1;
    while (b) {
        if (b % 2 == 1) {
            ans = ans * a % mod;
        }
        b /= 2;
        a = a * a % mod;
    }
    return ans;
}
struct node {
    int h[32];

    //线性基增加了return true
    bool in(int x) {
        for (int i = 31; i >= 0; i--) {
            if ((1ll << i) & x) {
                if (h[i] == 0) {
                    h[i] = x;
                    return true;
                } else {
                    x ^= h[i];
                }
            }
        }
        return false;
    }

    int ma(int x,int y) {
        for (int i = 31; i >= 0; i--) {
            if(ans>max(x^h[i],y^h[i])){
                ans=max(x^h[i],y^h[i]);
                x^=h[i];
                y^=h[i];
            }
        }
        return x;
    }
}t1;

void solve() {
    int n, m;
    cin >> n ;
    int ans=0;
    int p=0;
    for(int i=31;i>=0;i--){
        t1.h[i]=0;
    }
    vector<int>a(n+5),num(n+5);
    for(int i=1;i<=n;i++){
        cin>>a[i];
        num[a[i]]++;
        if(!t1.in(a[i])){
            p++;
        }
    }
    ans+=ksm(2,p)-1;
   // ans%=mod;
  //  ans+=mod;
    ans%=mod;
   // cout<<ans<<" ";
    for(int i=1;i<=n;i++){
        if(num[i]==0)continue;
        int c1=ksm(2,num[i]-1),c2=1;
        for(int j=1;j<=sqrt(i);j++){
            if(i%j==0){
                if(j!=i&&num[j]) {
                    c2 *= ksm(2, num[j] - 1);
                    c2 %= mod;
                }
                int f2=i/j;
                if(f2!=i&&f2!=j&&num[f2]){
                    c2*=ksm(2,num[f2]-1);
                    c2%=mod;
                }
            }
        }
        ans+=c1*c2%mod;
        ans%=mod;
        //cout<<ans<<" ";
    }
    cout <<ans << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // cout<<fixed<<setprecision(2);
    int T = 1;
    cin>>T;
    while (T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3576kb

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: 0
Accepted
time: 18ms
memory: 3612kb

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

result:

ok 40000 numbers

Test #3:

score: -100
Wrong Answer
time: 18ms
memory: 3612kb

input:

20000
10
1 3 6 8 3 1 10 7 2 3
10
8 2 8 9 10 5 8 4 8 3
10
2 2 10 1 6 4 4 3 4 7
10
6 5 10 7 8 7 3 1 6 6
10
3 2 3 7 8 4 9 8 8 7
10
9 9 6 4 9 3 9 10 5 9
10
10 8 9 10 10 4 5 1 4 3
10
2 10 4 5 8 10 2 2 7 2
10
2 6 4 10 1 1 1 1 2 3
10
1 10 2 8 1 5 9 4 3 1
10
8 1 8 1 9 5 6 7 2 9
10
1 6 7 4 8 8 7 3 5 7
10
10 ...

output:

89
77
80
74
75
84
75
105
143
95
81
74
78
73
73
73
83
93
90
84
79
77
73
89
77
73
81
79
80
175
83
77
83
76
83
85
84
97
74
80
101
74
113
74
75
95
75
83
86
77
99
73
77
83
91
96
77
80
77
76
80
81
73
95
83
74
75
81
77
79
74
76
78
81
97
77
85
73
92
83
73
80
73
77
74
73
142
83
99
78
91
77
76
81
77
74
78
76
...

result:

wrong answer 1st numbers differ - expected: '97', found: '89'