Submission #704766

# Submission time Handle Problem Language Result Execution time Memory
704766 2023-03-03T01:22:44 Z ancuber1031 Lutrija (COCI19_lutrija) C++14
14 / 70
43 ms 296 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

bool is_prime(int x) {
    if (x == 2) return 1;
    if (x%2 == 0 || x == 1) return 0;
    for (int i = 3; i*i <= x; i += 2) {
        if (x%i == 0) return 0;
    }
    return 1;
}

signed main() {
    int a, b; cin>>a>>b;
    if (is_prime(abs(a-b))) {
        cout<<2<<endl;
        cout<<a<<' '<<b<<endl;
    } else if (is_prime(a+b)) {
        cout<<3<<endl;
        cout<<a<<' '<<(a+b)<<' '<<b<<endl;
    } else if (is_prime(a-2) && is_prime(b-2)) {
        cout<<3<<endl;
        cout<<a<<' '<<2<<' '<<b<<endl;
    } else if (is_prime(a+2) && is_prime(abs(a+2-b))) {
        cout<<3<<endl;
        cout<<a<<' '<<a+2<<' '<<b<<endl;
    } else if (is_prime(a-2) && is_prime(abs(a-2-b))) {
        cout<<3<<endl;
        cout<<a<<' '<<a-2<<' '<<b<<endl;
    } else {
        cout<<-1<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 272 KB Output isn't correct
2 Halted 0 ms 0 KB -