Submission #445059

# Submission time Handle Problem Language Result Execution time Memory
445059 2021-07-16T10:40:39 Z Dipra_Irham Lutrija (COCI19_lutrija) C++14
14 / 70
96 ms 292 KB
#include "bits/stdc++.h"
#define pb(x) push_back(x)
#define fil(x, y) memset(x, y, sizeof(x))
#define ll long long
#define ff first
#define ss second
#define printp(x) x.ff << " " << x.ss
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp(x, y) make_pair(x,y)
#define inf 1073741823
#define infll 4611686018427387903
#define M 1000000007
#define db(x) cout << x << " ";
#define N 10000007
#define sz size
#define sm 0.0000007
#define ins insert
#define ers erase
#define all(k) k.begin(), k.end()
#define cnt count
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
using namespace std;



bool chk(ll n)
{
    ll sqrtn = sqrt(n + 1) + 1;
    bool g = 0;
    for(int i = 2;i <= sqrtn && i < n;i++)
    {
        if(n % i == 0)
        {
            return 0;
        }
    }
    return 1;
}
int main()
{
    fastio;
    ll a, b;
    cin >> a >> b;
    if(a == 2 && b == 2)
    {
        cout << 3 << endl;
        cout << 2 << " " << 5 << " " << 2 << endl;
    }
    else if(abs(b - a) == 2)
    {
        cout << 2 << endl;
        cout << a << " " << b << endl;
    }
    else if(a % 2 == 1 && b % 2 == 1)
    {
        bool g = 0;
        if(chk(a - 2) == 1 && (chk(b - 2) == 1))
        {
            cout << 3 << endl;
            cout << a << " " << 2 << " " << b << endl;
        }
        else if(chk(a - 2) == 1 && chk(b + 2) == 1)
        {
            cout << 4 << endl;
            cout << a << " " << 2 << " " << b + 2 << " " << b << endl;
        }
        else if(chk(a + 2) == 1 && chk(b - 2) == 1)
        {
            cout << 4 << endl;
            cout << a << " " << a + 2 << " " << 2 << " " << b << endl;
        }
        else
            cout << -1 << endl;
    }
    else
    {
        ll n = abs(b - a);
        if(chk(n) == 1)
        {
            cout << 2 << endl;
            cout << a << " " << b << endl;
        }
        else
        {
            vector <ll> mn;
            ll x = a;
            ll y = b;
            if(a % 2 == 0)
                swap(a, b);
            if(chk(a + 2))
                mn.pb(a + 2);
            if(chk(a - 2)){
                mn.pb(a - 2);
            }
            bool g = 0;
            for(int i = 0;i < mn.sz();i++)
            {
                if(chk(abs(mn[i] - b)) == 1)
                {
                    cout << 3 << endl;
                    cout << x << " " << mn[i] << " " << y << endl;
                    g = 1;
                    break;
                }
            }
            if(g == 0)
                cout << -1 << endl;
        }
    }
    return 0;
}

Compilation message

lutrija.cpp: In function 'bool chk(long long int)':
lutrija.cpp:30:10: warning: unused variable 'g' [-Wunused-variable]
   30 |     bool g = 0;
      |          ^
lutrija.cpp: In function 'int main()':
lutrija.cpp:57:14: warning: unused variable 'g' [-Wunused-variable]
   57 |         bool g = 0;
      |              ^
lutrija.cpp:97:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |             for(int i = 0;i < mn.sz();i++)
      |                           ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 80 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -