Submission #814852

# Submission time Handle Problem Language Result Execution time Memory
814852 2023-08-08T10:35:00 Z Tunglam07 Lutrija (COCI19_lutrija) C++17
42 / 70
140 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
 
vector<long long> ans;

bool isprime(long long x)
{
    if(x==1)
	{
        return false;
    }
    for(int i=2;i<=sqrt(x);i++)
	{
        if(x%i==0)
		{
            return false;
        }
    }
    return true;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a,b;
    cin >> a >> b;
    if(a==2)
	{
        ans = {2};
    }
    else
	{
        if(isprime(a-2))
		{
            ans = {a,2};
        }
        else if(isprime(a+2))
		{
            ans = {a,a+2,2};
        }
        else
		{
            cout << -1 << endl;
            return 0;
        }
    }
    if(b!=2)
	{
        if(isprime(b-2))
		{
            ans.push_back(b);
        }
        else if(isprime(b+2))
		{
            ans.push_back(b+2);
            ans.push_back(b);
        }
        else
		{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans.size() << endl;
    for(int i : ans)
	{
        cout << i << " ";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 0 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 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 131 ms 212 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 127 ms 300 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 140 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 212 KB Integer parameter [name=arr[4]] equals to -2070243847, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -