Submission #199474

# Submission time Handle Problem Language Result Execution time Memory
199474 2020-02-01T14:01:26 Z SamAnd Lutrija (COCI19_lutrija) C++17
7 / 70
203 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

bool stgg(long long x)
{
    if (x <= 1)
        return false;
    for (long long i = 2; i * i <= x; ++i)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

bool stg(const vector<long long>& v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        if (!stgg(v[i]))
            return false;
        if (!stgg(abs(v[i + 1] - v[i])))
            return false;
    }
    return true;
}

int main()
{
    long long a, b;
    scanf("%lld%lld", &a, &b);
    if (stg({a, b}))
    {
        printf("2\n%lld %lld\n", a, b);
        return 0;
    }
    if (stg({a, 2, b}))
    {
        printf("3\n%lld %lld %lld\n", a, 2, b);
        return 0;
    }
    if (a == 2)
    {
        if (stg({a, b + 2, b}))
        {
            printf("3\n%lld %lld %lld\n", a, b + 2, b);
            return 0;
        }
        if (stg({a, b - 2, b}))
        {
            printf("3\n%lld %lld %lld\n", a, b - 2, b);
            return 0;
        }
    }
    if (b == 2)
    {
        if (stg({a, a + 2, b}))
        {
            printf("3\n%lld %lld %lld\n", a, a + 2, b);
            return 0;
        }
        if (stg({a, a - 2, b}))
        {
            printf("3\n%lld %lld %lld\n", a, a - 2, b);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Compilation message

lutrija.cpp: In function 'bool stg(const std::vector<long long int>&)':
lutrija.cpp:18:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size() - 1; ++i)
                     ~~^~~~~~~~~~~~~~
lutrija.cpp: In function 'int main()':
lutrija.cpp:39:46: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'int' [-Wformat=]
         printf("3\n%lld %lld %lld\n", a, 2, b);
                                              ^
lutrija.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld", &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 203 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -