| Task: | Tekijät |
| Sender: | Metabolix |
| Submission time: | 2020-11-06 21:32:50 +0200 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 12 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 12 |
| #2 | TIME LIMIT EXCEEDED | 0 |
| #3 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #3 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #4 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #5 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #6 | ACCEPTED | 0.39 s | 3 | details |
| #7 | WRONG ANSWER | 0.10 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:31:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < alkuluvut.size(); ++j) {
~~^~~~~~~~~~~~~~~~~~
input/code.cpp:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < alkuluvut.size(); ++i) {
~~^~~~~~~~~~~~~~~~~~
input/code.cpp:47:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = i+1; j < alkuluvut.size(); ++j) {
~~^~~~~~~~~~~~~~~~~~Code
#include <bits/stdc++.h>
std::unordered_map<int, std::unordered_set<int>> luvut;
std::vector<int> alkuluvut {2, 3};
void uusi_alkuluku(int i) {
bool ok = true;
for (int j: alkuluvut) {
if (i % j == 0) {
ok = false;
break;
}
}
if (ok) {
alkuluvut.push_back(i);
}
}
int main() {
for (int i = 5; i < 1000; i += 2) {
uusi_alkuluku(i);
}
int n;
long isot = 0;
std::cin >> n;
std::vector<int> t(n);
std::vector<std::bitset<6 * 32>> b(n);
for (int i = 0; i < n; ++i) {
std::cin >> t[i];
bool pienin_tekija = false;
for (int j = 0; j < alkuluvut.size(); ++j) {
if (t[i] % alkuluvut[j] == 0) {
b[i].set(j);
if (!pienin_tekija) {
pienin_tekija = true;
luvut[j].insert(i);
}
}
}
if (!pienin_tekija) {
isot += 1;
}
}
long tulos = isot * (n - isot) + isot * (isot - 1) / 2;
for (int i = 0; i < alkuluvut.size(); ++i) {
for (int ii: luvut[i]) {
for (int j = i+1; j < alkuluvut.size(); ++j) {
if (b[ii].test(j)) {
continue;
}
for (auto jj: luvut[j]) {
if ((b[ii] & b[jj]).none()) {
tulos += 1;
}
}
}
}
}
std::cout << tulos << std::endl;
}
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 3043 |
| user output |
|---|
| 3043 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 71 19 26 18 57 78 80 89 31 26 ... |
| correct output |
|---|
| 3086 |
| user output |
|---|
| 3086 |
Test 3
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 66 87 90 67 93 89 57 29 34 4 8... |
| correct output |
|---|
| 3044751906 |
| user output |
|---|
| (empty) |
Test 4
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
| correct output |
|---|
| 3039650753 |
| user output |
|---|
| (empty) |
Test 5
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 238907 151373 522599 885657 37... |
| correct output |
|---|
| 3031155756 |
| user output |
|---|
| (empty) |
Test 6
Group: 3
Verdict: ACCEPTED
| input |
|---|
| 100000 510510 510510 510510 510510 51... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 0 |
Test 7
Group: 3
Verdict: WRONG ANSWER
| input |
|---|
| 100000 999983 999983 999983 999983 99... |
| correct output |
|---|
| 0 |
| user output |
|---|
| 4999950000 |
