Submission #849852

# Submission time Handle Problem Language Result Execution time Memory
849852 2023-09-15T13:11:16 Z tiwerlol Lutrija (COCI19_lutrija) C++17
49 / 70
1 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

ofstream fout("xor.out");
ifstream fin("xor.in");

#define miauDebug
#ifdef miauDebug
#define mau(x) MIAUMIAU(#x, x)
#else
#define mau(x)
#endif

void MIAUMIAU(const char* var_name, auto var_value) {
    cout << var_name << " = " << var_value << endl;
}

using ll = long long;
const int nM = 2e5+5;
const ll MOD = 1e9 + 7;
// :3

bool prim(ll a)
{
    if(a==2 || a==3)
        return 1;

    if(a%2==0 || a%3==0 || a%5==0 || a%7==0)
        return 0;

    for(ll z = 0; z*z <= a; z+=6)
    {
        if((a%(z-1)==0) || (a%(z+1)==0))
            return 1;
    }
    return 0;
}

void solve() {
    ll a, b; cin >> a >> b;

    if(prim(abs(a-b)))
    {
        cout << 2 << '\n';

        cout << a << ' ' << b << '\n';
        return;
    }

    if(a==2)
    {
        if(prim(b+2)) cout << 3 << '\n' << a << ' ' << b+2 << ' ' << b;
        else cout << -1 << '\n';
        return;
    }

    if(b==2)
    {
        if(prim(a+2)) cout << 3 << '\n' << a << ' ' << a+2 << ' ' << b;
        else cout << -1 << '\n';
        return;
    }

    if(prim(a-2) && prim(b-2))
    {
        cout << 3 << '\n';
        cout << a << ' ' << 2 << ' ' << b;
        return;
    }

    if(prim(a-2) && prim(b+2))
    {
        cout << 4 << '\n';
        cout << a << ' ' << 2 << ' ' << b+2 << ' ' << b;
        return;
    }

    if(prim(a+2) && prim(b-2))
    {
        cout << 4 << '\n';
        cout << a << ' ' << a+2 << ' ' << 2 << ' ' << b;
        return;
    }

    if(prim(a+2) && prim(b+2))
    {
        cout << 5 << '\n';
        cout << a << ' ' << a+2 << ' ' << 2 << ' ' << b+2 << ' ' << b;
        return;
    }

    cout << "-1";
}
signed main()
{
    cout.tie(NULL);
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    int tt = 1; //cin >> tt;

    while(tt--)
        solve();
}

Compilation message

lutrija.cpp:14:37: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   14 | void MIAUMIAU(const char* var_name, auto var_value) {
      |                                     ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Failed 1 ms 344 KB user found solution while jury couldn't
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 504 KB Output is correct