Submission #838161

# Submission time Handle Problem Language Result Execution time Memory
838161 2023-08-26T09:48:30 Z LinkedArray Lutrija (COCI19_lutrija) C++17
56 / 70
79 ms 304 KB
#include <bits/stdc++.h>
using namespace std;

bool isPrime(long long num) {
    long long d;

    if (num % 2 == 0)
        return 0;
    for (d = 3; d * d <= num; d += 2) {
        if (num % d == 0) {
            return 0;
        }
    }

    return 1;
}

int main() {
    long long a, b, AP2, AM2, BP2, BM2, nr;

    cin >> a >> b;

    AP2 = isPrime(a + 2);
    AM2 = isPrime(a - 2);

    BP2 = isPrime(b + 2);
    BM2 = isPrime(b - 2);

    if (a != 2 && !AP2 && !AM2) {
        cout << "-1";
    } else if (b != 2 && !BP2 && !BM2) {
        cout << "-1";
    } else {
        nr = 1 + AM2 + BM2 + 2 * (AP2 + BP2);

        cout << nr << '\n';
        cout << (AM2 ? to_string(a) + ' ' : (AP2 ? to_string(a) + ' ' + to_string(a + 2) + ' ' : "")) 
             << "2"
             << (BM2 ? ' ' + to_string(b) : (BP2 ? ' ' + to_string(b + 2) + ' ' + to_string(b) : ""));
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 212 KB Output is correct
2 Correct 39 ms 280 KB Output is correct
3 Correct 79 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 272 KB Output is correct
2 Correct 39 ms 304 KB Output is correct
3 Correct 57 ms 280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 276 KB Output is correct
2 Correct 37 ms 212 KB Output is correct
3 Correct 52 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 280 KB Output is correct
2 Correct 29 ms 276 KB Output is correct
3 Correct 19 ms 288 KB Output is correct