ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#197141 | #2444. 自同构 | tkswls | 100 | 28ms | 1548kb | C++11 | 1.2kb | 2023-11-07 10:35:55 | 2023-11-07 12:10:17 |
answer
#include <bits/stdc++.h>
using namespace std;
int n, a[505], cnt, ccnt;
bitset<4005>b[505];
unordered_map<int, int> ma;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
for (int j = 2; j * j <= a[i]; j++) {
while (a[i] % (j * j) == 0) {
a[i] /= j * j;
}
}
if (a[i] == 1) {
a[i] = 0;
}
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++) {
for (int j = 2; j * j < a[i]; j++) {
if (a[i] % j == 0) {
a[i] /= j;
if (ma.find(j) == ma.end()) {
ma[j] = ++ccnt;
}
b[i][ma[j]] = 1;
}
}
if (a[i]) {
if (ma.find(a[i]) == ma.end()) {
ma[a[i]] = ++ccnt;
}
b[i][ma[a[i]]] = 1;
}
}
int lst = 0, maxn = -1;
for (int i = 1; i <= ccnt && lst < n; i++) {
maxn = 0;
for (int j = lst + 1; j <= n; j++) {
if (b[j][i]) {
maxn = j;
}
}
if (maxn == 0) continue;
swap(b[lst + 1], b[maxn]);
lst++;
for (int j = lst + 1; j <= n; j++) {
if (b[j][i]) {
b[j] = b[j] ^ b[lst];
}
}
}
long long ans = 1;
for (int i = 1; i <= lst; i++) {
ans = ans * 2;
ans %= 1000000007;
}
cout << ans;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1520kb
input:
5 34 57 57 39 19
output:
16
result:
ok 1 number(s): "16"
Test #2:
score: 10
Accepted
time: 0ms
memory: 1516kb
input:
5 53 89 85 1 73
output:
16
result:
ok 1 number(s): "16"
Test #3:
score: 10
Accepted
time: 1ms
memory: 1520kb
input:
19 9802059 6825390 5046093 8035993 5292482 5123360 7038798 7883070 1544818 6882527 9529015 2979795 3...
output:
524288
result:
ok 1 number(s): "524288"
Test #4:
score: 10
Accepted
time: 0ms
memory: 1520kb
input:
20 6830902 5702906 7016405 1340963 6768895 3445954 7139965 3776003 9152545 2801120 3893910 3922081 2...
output:
1048576
result:
ok 1 number(s): "1048576"
Test #5:
score: 10
Accepted
time: 1ms
memory: 1520kb
input:
400 1918 1228 311 1974 1634 2088 1123 2158 1053 2200 1123 2273 2419 1169 933 1523 2047 2743 1507 151...
output:
248320570
result:
ok 1 number(s): "248320570"
Test #6:
score: 10
Accepted
time: 0ms
memory: 1528kb
input:
500 1753 2095 1847 2768 2753 2362 1157 1777 1597 2957 1243 641 2203 1478 2467 2471 2699 337 2066 165...
output:
993526229
result:
ok 1 number(s): "993526229"
Test #7:
score: 10
Accepted
time: 7ms
memory: 1532kb
input:
480 4028334 9221377 5322197 8722753 9203050 3960133 7962231 7368927 6219749 6764483 9082247 5322197 ...
output:
779974913
result:
ok 1 number(s): "779974913"
Test #8:
score: 10
Accepted
time: 5ms
memory: 1540kb
input:
490 9396439 7799406 4747098 3203269 8076610 8512674 5182167 4581241 7740133 4998046 9191494 5049813 ...
output:
199161894
result:
ok 1 number(s): "199161894"
Test #9:
score: 10
Accepted
time: 7ms
memory: 1548kb
input:
500 3557578 3158603 7940111 962809 7537625 5322103 7216021 4925147 9988786 6237100 2313921 9834442 1...
output:
136896910
result:
ok 1 number(s): "136896910"
Test #10:
score: 10
Accepted
time: 7ms
memory: 1548kb
input:
500 9366729 5436407 3648433 7858699 9921238 9606703 9634282 6249377 2924693 7757039 9225887 7797863 ...
output:
730952599
result:
ok 1 number(s): "730952599"