Submission #378222

# Submission time Handle Problem Language Result Execution time Memory
378222 2021-03-16T09:19:12 Z bibabas Lutrija (COCI19_lutrija) C++14
42 / 70
173 ms 508 KB
// #define _FORTIFY_SOURCE 0 
// #pragma GCC optimize("Ofast") 
// #pragma GCC optimize("no-stack-protector") 
// #pragma GCC optimize("unroll-loops") 
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") 
// //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
// #pragma GCC optimize("inline") 
// #pragma GCC optimize("-fgcse") 
// #pragma GCC optimize("-fgcse-lm") 
// #pragma GCC optimize("-fipa-sra") 
// #pragma GCC optimize("-ftree-pre") 
// #pragma GCC optimize("-ftree-vrp") 
// #pragma GCC optimize("-fpeephole2") 
// #pragma GCC optimize("-ffast-math") 
// #pragma GCC optimize("-fsched-spec") 
// #pragma GCC optimize("unroll-loops") 
// #pragma GCC optimize("-falign-jumps") 
// #pragma GCC optimize("-falign-loops") 
// #pragma GCC optimize("-falign-labels") 
// #pragma GCC optimize("-fdevirtualize") 
// #pragma GCC optimize("-fcaller-saves") 
// #pragma GCC optimize("-fcrossjumping") 
// #pragma GCC optimize("-fthread-jumps") 
// #pragma GCC optimize("-funroll-loops") 
// #pragma GCC optimize("-fwhole-program") 
// #pragma GCC optimize("-freorder-blocks") 
// #pragma GCC optimize("-fschedule-insns") 
// #pragma GCC optimize("inline-functions") 
// #pragma GCC optimize("-ftree-tail-merge") 
// #pragma GCC optimize("-fschedule-insns2") 
// #pragma GCC optimize("-fstrict-aliasing") 
// #pragma GCC optimize("-fstrict-overflow") 
// #pragma GCC optimize("-falign-functions") 
// #pragma GCC optimize("-fcse-skip-blocks") 
// #pragma GCC optimize("-fcse-follow-jumps") 
// #pragma GCC optimize("-fsched-interblock") 
// #pragma GCC optimize("-fpartial-inlining") 
// #pragma GCC optimize("no-stack-protector") 
// #pragma GCC optimize("-freorder-functions") 
// #pragma GCC optimize("-findirect-inlining") 
// #pragma GCC optimize("-fhoist-adjacent-loads") 
// #pragma GCC optimize("-frerun-cse-after-loop") 
// #pragma GCC optimize("inline-small-functions") 
// #pragma GCC optimize("-finline-small-functions") 
// #pragma GCC optimize("-ftree-switch-conversion") 
// #pragma GCC optimize("-foptimize-sibling-calls") 
// #pragma GCC optimize("-fexpensive-optimizations") 
// #pragma GCC optimize("-funsafe-loop-optimizations") 
// #pragma GCC optimize("inline-functions-called-once") 
// #pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>

using namespace std;
         
#define ll long long
#define ull unsigned ll
#define vi vector<ll>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ld long double
#define pii pair<ll, ll>
#define mt make_tuple
#define mn(a, b) a = min(a, b)
#define mx(a, b) a = max(a, b)
#define base complex<ld>
 
using namespace std;
const ll INF = (ll)2e9;
const ll inf = (ll)1e18;
const ld eps = (ld)1e-12;
const ll mod = (ll)1e9 + 7;
const ll p = 31;
const ll mod2 = (ll)1e9 + 7;
const ll MAXN = (ll)500 + 1;
const ll MAXC = (ll)1e6 + 11;
const ll MAXE = (ll)100;
const ll MAXLOG = (ll)19;
const ll asci = (ll)256;
const ll block = 31623;
const ld PI = acos(-1LL);
const ld e = 2.7182818284;
         
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<
// pii,
// null_type,
// less<pii>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

ll int_rand() {
    if (RAND_MAX == (1LL << 15) - 1LL) {
        return (rand() << 15) + rand();
    }
    return rand();
}

ll ll_rand() {
    return ((ll)int_rand() << 30LL) + int_rand();
}

istream& operator >>(istream &in, pii &x) {
    cin >> x.first >> x.second;
    return in;
}
         
template <class T>
istream& operator >>(istream &in, vector<T> &arr){
    for (T &cnt : arr) {
        in >> cnt;
    }
    return in;
}

bool prime(ll x) {
    if (x < 2) return 0;
    for (ll i = 2; i * i <= x; ++i) {
        if (x % i == 0) return 0;
    }
    return 1;
}

void solve() {
    ll a, b; cin >> a >> b;
    if (prime(abs(a - b))) {
        cout << "2\n";
        cout << a << " " << b << "\n";
        return;
    }
    vi ans;
    bool c1 = prime(a - 2);
    bool c2 = prime(a + 2);
    bool c3 = a == 2;
    if (c1) {
        ans.push_back(a);
        ans.push_back(2);
    } else if (c2) {
        ans.push_back(a);
        ans.push_back(a + 2);
        ans.push_back(2);
    } else if (c3) {
        ans.push_back(2);
    } else {
        cout << "-1\n";
        return;
    }
    c1 = prime(b - 2);
    c2 = prime(b + 2);
    c3 = b == 2;
    if (c1) {
        ans.push_back(b);
    } else if (c2) {
        ans.push_back(b + 2);
        ans.push_back(b);
    } else if (c3) {
    } else {
        cout << "-1\n";
        return;
    }
    cout << ans.size() << "\n";
    for (int i : ans) cout << i << " ";
}

signed main() {
    srand(time(0LL));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr); 
#endif
    cout.precision(30);
    
    solve();

    return 0LL;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 492 KB Integer parameter [name=arr[4]] equals to -2039078211, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 392 KB Integer parameter [name=arr[1]] equals to -2145466189, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 173 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 126 ms 508 KB Integer parameter [name=arr[4]] equals to -2070243847, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -