#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
#define int ll
bool isprime(ll p){
for(ll i=2;i<=sqrt(p);i++){
if(p%i==0) return 0;
}
return 1;
}
bool twin(ll G){
if(G%6==5){
return (isprime(G+2)) ;
}else if(G%6==1){
return isprime(G-2);
}
return 0;
}
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
ll A,B;cin>>A>>B;
if((twin(A)||A==2) && (twin(B)||B==2)){
if(A==2){
if(B%6==5){
cout<<3<<"\n";
cout<<A<<" "<<B+2<<" "<<B<<"\n";
return 0;
}else{
cout<<2<<"\n";
cout<<A<<" "<<B<<"\n";
return 0;
}
}
if(B==2){
if(A%6==5){
cout<<3<<"\n";
cout<<B<<" "<<A+2<<" "<<A<<"\n";
return 0;
}else{
cout<<2<<"\n";
cout<<B<<" "<<A<<"\n";
return 0;
}
}
if(abs(A-B)==2){
cout<<2<<"\n";
cout<<A<<" "<<B<<"\n";
return 0;
}
vector<int> ans;
ans.push_back(A);
if(A%6==5){
ans.push_back(A+2);
}
ans.push_back(2);
if(B%6==5){
ans.push_back(B+2);
}
ans.push_back(B);
cout<<ans.size()<<"\n";
for(auto i : ans) cout<<i<<" ";
cout<<"\n";
}else{
cout<<-1<<"\n";
}
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 |
288 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
148 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
170 ms |
308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
134 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
122 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
151 ms |
292 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
110 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
110 ms |
296 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
44 ms |
212 KB |
Output is correct |