QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#467710#7679. Master of Both IVlouisliangWA 11ms3624kbC++141.4kb2024-07-08 17:13:082024-07-08 17:13:09

Judging History

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

  • [2024-07-08 17:13:09]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3624kb
  • [2024-07-08 17:13:08]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#define lowbit(x) (x & (-x))
using namespace std;
const int N = 2e5 + 10, MOD = 998244353;
int k[25], n, t[N], cnt;
long long qpow(long long x, long long k){
	long long ret = 1;
	while(k){
		if(k & 1)
			ret = ret * x % MOD;
		x = x * x % MOD, k >>= 1;
	}
	return ret;
}
void ins(int x){
	for(int i = 20; ~i; i--){
		if((x >> i) & 1){
			if(k[i])
				x ^= k[i];
			else{
				k[i] = x, cnt++;
				break;
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	int Cases;
	cin >> Cases;
	while(Cases--){
		cin >> n;
		memset(k, 0, sizeof(k));
		memset(t, 0, sizeof(int) * (n + 1));
		cnt = 0;
		for(int i = 1, x; i <= n; i++){
			cin >> x;
			t[x]++;
			ins(x);
		}
		long long ans = qpow(2, n - cnt) - 1;
		for(int i = 1; i <= n; i++){
			if(t[i]){
				int sum = 0;
				cnt = 0;
				memset(k, 0, sizeof(k));
				for(int j = 1; j * j <= i && j < i; j++){
					if(i % j == 0){
						if(t[j]){
							sum += t[j];
							ins(j);
						}
						if(i / j != j && i / j != i && t[i / j]){
							sum += t[i / j];
							ins(i / j);
						}
					}
				}
				long long as = t[i], C = t[i];
				for(int i = 3; i <= t[i]; i += 2)
					C = C * (t[i] - i + 2) % MOD * (t[i] - i + 1) % MOD, as = (as + C) % MOD;
				ans = (ans + as * qpow(2, sum - cnt)) % MOD;
			}
		}
		cout << ans << endl;
	}
} 


详细

Test #1:

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

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: 11ms
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:

8
12
8
9
8
8
8
8
8
9
22
8
8
8
8
9
12
9
11
14
8
8
15
12
8
11
8
8
8
12
15
9
9
8
8
8
11
9
11
12
15
8
15
8
8
8
8
12
11
8
8
11
8
8
11
15
9
8
9
8
8
14
11
8
31
9
15
8
8
8
12
9
8
11
8
13
9
8
14
8
8
8
8
8
8
15
8
11
22
8
9
11
8
18
11
13
18
15
12
14
8
8
8
9
8
8
12
15
15
18
9
15
9
11
8
8
11
8
9
11
8
9
8
22
15
1...

result:

wrong answer 1st numbers differ - expected: '9', found: '8'