Submission #747243

# Submission time Handle Problem Language Result Execution time Memory
747243 2023-05-24T02:08:46 Z Trunkty Lutrija (COCI19_lutrija) C++14
70 / 70
171 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

bool isprime(int x){
    if(x==1){
        return false;
    }
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

vector<int> ans;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int 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 << "\n";
            return 0;
        }
    }
    if(b==2){
        // do nothing
    }
    else{
        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 << "\n";
            return 0;
        }
    }
    cout << ans.size() << "\n";
    for(int i:ans){
        cout << i << " ";
    }
    cout << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 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 0 ms 212 KB Output is correct
4 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 0 ms 212 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 Correct 1 ms 212 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 171 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 304 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 126 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 292 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 112 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 332 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 41 ms 212 KB Output is correct