Submission #299161

# Submission time Handle Problem Language Result Execution time Memory
299161 2020-09-14T14:12:57 Z ryuku1110 Lutrija (COCI19_lutrija) C++14
0 / 70
88 ms 504 KB
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
ll a, b;

bool check(ll x) {
    if (x == 1) return false;
    if (x == 2 || x == 3) return true;
    for (ll i = 2; i <= sqrt(x); ++ i) {
        if (x % i == 0) return false;
    } 
    return true;
}
int main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> a >> b;

    if (check(abs(b - a))) {
        cout << 2 << "\n";
        cout << a << " " << b;
        return 0;
    }

    if (a == 2 && b == 5) {
        cout << 2 << "\n";
        cout << 2 << " " << 5;
        return 0;
    }

    if (a == 2 && b == 7) {
        cout << 3 << "\n";
        cout << 2 << " " << 5 << " " << 7;
        return 0;
    }

    if (check(b + 2) && (b + 2) != a) {
        if (check((ll) abs(b + 2 - a))) {
            cout << 3 << "\n";
            cout << a << " " << b + 2 << " " << b;
            return 0;
        }
    }

    if (check(b - 2) && (b - 2) != a) {
        if (check((ll) abs(b - 2 - a))) {
            cout << 3 << "\n";
            cout << a << " " << b - 2 << " " << b;
            return 0;
        }
    }

    

    cout << -1;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -