Submission #1308615

#TimeUsernameProblemLanguageResultExecution timeMemory
1308615mrasool1665Lutrija (COCI19_lutrija)C++20
0 / 70
2 ms348 KiB
//MRasool Kheyri 
//Iran , BandarAbbas
//16/10/1404
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define el '\n'
#define lid id<<1
#define rid lid|1
#define mid (l+r)/2 
const ll maxn = 1e6 + 100 ;
const ll mod = 1e9 + 7 ;
const ll oo = 1e18 + 100 ;
bool is_prime(ll x){
    if(x < 2){return 0;}
    for(ll i = 2 ; i*i <= x ; i++){
        if(x%i == 0){
            return 0 ;
        }
    }
    return 1 ;
}
void solve(){
    ll a , b ;
    cin>>a>>b ;
    vector<ll> vec ;
    ll ok = 0 ;
    if(b < a){swap(a,b);ok=1;}
    if(a == 2){
        if(b == 3){
            vec.push_back(2) ;
            vec.push_back(5) ;
            vec.push_back(3) ;
        }
        if(b == 5){
            vec.push_back(2) ;
            vec.push_back(5) ;
        }
    }
    if(a == 3){
        if(b == 5){
            vec.push_back(3) ;
            vec.push_back(5) ;
        }
    }
    if(b-a == 2){
        vec.push_back(a) ;
        vec.push_back(b) ;
    }
    else if(a == 2){
        if(is_prime(b-2)){
            vec.push_back(2) ;
            vec.push_back(b) ;
        }
        else if(is_prime(b+2)){
            vec.push_back(2) ;
            vec.push_back(b+2) ;
            vec.push_back(b) ;
        }
    }
    if(ok){
        reverse(vec.begin(),vec.end()) ;
    }
    if(!vec.size()){
        cout<<-1<<el ;
        return ;
    }
    cout<<vec.size()<<el ;
    for(auto x : vec){
        cout<<x<<" ";
    }cout<<el ;
    return ;
}
int main(){
    //ios_base::sync_with_stdio(0) , cin.tie(nullptr) , cout.tie(nullptr) ;
    ll t = 1 ;
    //cin>>t ;
    while(t--){
        solve() ;
    }
    return 0 ;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...