답안 #939930

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939930 2024-03-07T01:17:45 Z 12345678 Lutrija (COCI19_lutrija) C++17
70 / 70
141 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll a, b;
vector<ll> ans;

bool isprime(ll x)
{
    ll t=sqrt(x);
    if (x==0||x==1) return 0;
    if (x==2) return 1;
    for (ll i=2; i<=t; i++) if (x%i==0) return 0;
    return 1; 
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>a>>b;
    if (isprime(abs(b-a))) return cout<<2<<'\n'<<a<<' '<<b, 0;
    ans.push_back(a);
    if (isprime(a-2)&&a!=2) ans.push_back(2);
    else if (isprime(a+2)&&a!=2) ans.push_back(a+2), ans.push_back(2);
    else if (a!=2) return cout<<-1, 0;
    if (b==2)
    {
        cout<<ans.size()<<'\n';
        for (auto x:ans) cout<<x<<' ';
        return 0;
    }
    if (isprime(b-2)) ans.push_back(b);
    else if (isprime(b+2)) ans.push_back(b+2), ans.push_back(b);
    else return cout<<-1, 0;
    cout<<ans.size()<<'\n';
    for (auto x:ans) cout<<x<<' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 428 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 428 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 424 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct