#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define int long long
#define double long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define what_is(x) cerr << #x << " is " << x << endl;
const int N=200005;
const long long INF = LLONG_MAX;
const int INF2=(int)1e18;
const int LOG=20;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tp;
typedef priority_queue<pii,vector<pii>,greater<pii>> min_pq;
typedef priority_queue<pii> max_pq;
typedef long long ll;
//sunlari dusun//
/*
* kodu kisaltcak fonksiyon
* cevaba binary search ya da normal bs
* segment tree / sparse table
* stack
* teklik ciftlik
* precomputation
* EN ONEMLISI OVERKILLEME
* edge case dusunr
* constraintlere bak
* indisleri kontrol et
* dp
* greedy
* sorting
* dfs bfs
* sieve
*/
bool p(int a)
{
if(a<=1) return 0;
for(int i=2;i*i<=a;i++) if(a%i==0) return 0;
return 1;
}
void solve()
{
int a,b;
cin >> a >>b;
if(p( abs(a-b) ) )
{
cout << 2 << "\n" << a << " " << b << endl;
return;
}
int ok1=0,ok2=0;
if(a==2) ok1=1;
else if(p(a-2)) ok1=2;
else if(p(a+2)) ok1=3;
if(b==2) ok2=1;
else if(p(b-2)) ok2=2;
else if(p(b+2)) ok2=3;
if(ok1 && ok2)
{
int cnt=2;
if(ok1==2) cnt+=1;
if(ok1==3) cnt+=2;
if(ok2==2) cnt+=1;
if(ok2==3) cnt+=2;
cnt++;
cout << cnt << endl;
if(ok1==2) cout << a << " " << 2 << " ";
else if(ok1==3) cout << a << " " << a+2 <<" " << 2 << " ";
else cout << 2 << " ";
cout << 5 << " ";
if(ok2==2) cout << 2 << " " << b;
else if(ok2==3) cout << 2 <<" " << b+2 << " " << b;
else cout << b << endl;
}
else cout << -1 << endl;
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
cout << fixed << setprecision(15);
int t=1;//cin>> t;
while(t--) solve();
return 0;
}
# |
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 |
212 KB |
Output is correct |
4 |
Correct |
1 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 |
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 |
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 |
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 |
83 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
300 KB |
Output is correct |
2 |
Correct |
80 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
150 ms |
292 KB |
Output is correct |
2 |
Correct |
78 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
292 KB |
Output is correct |
2 |
Correct |
60 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |