#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll _i=0;
#define ffn(x) _i=x
#define llll pair<ll , ll>
#define stitr set<llll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define debu cout << "hello\n"
#define fi first
#define sec second
const ll limit = 1e9+7;
const ll ous=1e5 + 5;
const ll dx[4] = {1 , -1 , 0 , 0} , dy[4] = {0,0,-1,1};
ll pf(ll x){
ll y = sqrt(x);
if(x == 1){
return 0;
}
for(ll i = 2;y >= i;i++){
if(x % i == 0){
return 0;
}
}
return 1;
}
void solve(){
ll l , r;
cin >> l >> r;
if(l!=2 && r!=2){
if(abs(r-l) == 2){
cout <<"2\n"<< l << " " << r;
return;
}
else{
cout << -1 << "\n";
return;
}
}
else{
if(l != 2){
ll s= l-2;
if(pf(s)){
cout << 2 << "\n" << l << " " << r;
}
else if(pf(s) && pf(s-2)){
cout << 3 << "\n" << l << " " << s << " " << r;
}
else if(pf(l+2)){
cout << 3 << "\n" << l <<" "<<l+2 << " " << r;
}
else{
cout << -1 << "\n";
return;
}
}
else{
ll o = r-2;
if(pf(o)){
cout << "2\n" << l << " " << r ;
}
else if(pf(o) && pf(o-2)){
cout << 3 << "\n" << l << " " << o << " " << r;
}
else if(pf(r+2)){
cout << 3 << "\n" << l <<" "<< r+2 << " " << r;
}
else{
cout << "-1\n";
return;
}
}
}
return;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
ll t=1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |