Submission #319326

# Submission time Handle Problem Language Result Execution time Memory
319326 2020-11-04T19:50:44 Z gustason Lutrija (COCI19_lutrija) C++14
0 / 70
87 ms 388 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool isPrime(ll n) {
    if (n < 2) return false;
    for(ll i = 2; i*i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B;
    cin >> A >> B;
    bool ok = 0;
    if (abs(A - B) == 2) {
        cout << 2 << "\n"
             << A << " " << B;
        ok = 1;
    } else {
        if (isPrime(B - 2) && isPrime(abs(A - (B - 2)))) {
            cout << 3 << "\n"
                 << A << " " << B - 2 << " " << B << "\n";
            ok = 1;
        } else if (isPrime(B + 2) && isPrime(abs(A - (B + 2)))) {
            cout << 3 << "\n"
                 << A << " " << B + 2 << " " << B << "\n";
            ok = 1;
        }
    }
    if (!ok) {
        cout << -1;
    }
    return 0;
}
//~ check for overflows
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -