This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
bool prime(int x){
for(int i = 2; i * i <= x; i++){
if(x % i == 0) return false;
}
return true;
}
void solve(){
int a,b;
cin >> a >> b;
if(prime(abs(a-b))){
cout << "2\n" << a << ' ' << b << endl;
return;
}
if(a == 2 && b == 5){
cout << "3\n" << "2 3 5" << endl;
return;
}
if(a == 5 && b == 2){
cout << "3\n" << "5 3 2" << endl;
return;
}
if(a == 3 && b == 7){
cout << "3\n" << "3 5 7" << endl;
return;
}
if(a == 7 && b == 3){
cout << "3\n" << "7 5 3" << endl;
return;
}
if(a == 2){
if(prime(b + 2)){
cout << "3\n" << a << ' ' << b + 2 << ' ' << b << endl;
}
else cout << -1 << endl;
}
else if(b == 2){
if(prime(a + 2)){
cout << "3\n" << a << ' ' << a + 2 << ' ' << b << endl;
}
else cout << -1 << endl;
}
else cout << -1 << endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |