QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#612457 | #7679. Master of Both IV | zhangboju | WA | 20ms | 10348kb | C++17 | 1.7kb | 2024-10-05 11:21:32 | 2024-10-05 11:21:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2e5 + 5, mod = 1e9 + 7;
struct Base{
int a[20];
void init() {
for (int i = 0; i < 20; i++)
a[i] = 0;
}
void insert(int x) {
for (int i = 19; i >= 0; i--) {
if (!((x >> i) & 1)) {
continue;
}
if (!a[i]) {
a[i] = x;
break;
}
x ^= a[i];
}
}
int count() {
int cnt = 0;
for (int i = 0; i < 20; i++)
if (a[i])
cnt++;
return cnt;
}
};
int n;
int pw[N];
int a[N];
int cnt[N];
vector<int> d[N];
void solve() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
cnt[a[i]]++;
}
for (int i = 1; i <= n; i++)
for (int j = 2 * i; j <= n; j += i)
d[j].push_back(i);
Base alls;
alls.init();
for (int i = 1; i <= n; i++)
alls.insert(a[i]);
int ans = pw[n - alls.count()] - 1;
for (int i = 1; i <= n; i++) {
if (!cnt[i]) continue;
Base B;
B.init();
int sum = 0;
for (int x : d[i]) {
if (cnt[x]) {
B.insert(x);
sum += cnt[x];
}
}
ans = (ans + 1ll * cnt[i] * pw[sum - B.count()]) % mod;
}
printf("%d\n", ans);
}
void clear() {
for (int i = 0; i <= n; i++)
cnt[i] = 0, d[i].clear();
}
int main() {
pw[0] = 1;
for (int i = 1; i < N; i++)
pw[i] = 2ll * pw[i - 1] % mod;
int T;
scanf("%d", &T);
while (T--) {
solve();
clear();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 9976kb
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: 20ms
memory: 10348kb
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 12 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 15 9 15 8 8 8 12 9 8 11 8 13 9 8 14 8 8 8 8 8 8 15 8 11 12 8 9 11 8 18 11 13 18 15 12 14 8 8 8 9 8 8 12 15 15 8 9 15 9 11 8 8 11 8 9 11 8 9 8 12 15 11...
result:
wrong answer 1st numbers differ - expected: '9', found: '8'