#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)
{
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;
cout << a << " ";
if(ok1==2) cout << 2 << " ";
if(ok1==3) cout << a+2 <<" " << 2 << " ";
cout << 5 << " ";
if(ok2==2) cout << 2 << " " << b;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
145 ms |
300 KB |
Output is correct |
2 |
Correct |
85 ms |
300 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
137 ms |
296 KB |
Output is correct |
2 |
Correct |
83 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
150 ms |
300 KB |
Output is correct |
2 |
Correct |
79 ms |
312 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
116 ms |
212 KB |
Output is correct |
2 |
Correct |
61 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |