#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3dDwnkq ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
bool prime(ll c){
if(c==2) return true;
for(ll j=2;j<=sqrt(c);j++){
if(c%j==0){
return false;
}
}
return true;
}
vec(ll) pans,now;
std::map<vec(ll),int> mp;
void f(ll a,ll b){
if(mp.find(now)!=mp.end()) return;
mp[now]=1;
now.pb(a);
if(a==b){
pans=now;
return;
}
if(prime(a+2)){
f(a+2,b);
}
if(a-2>0 and prime(a-2)){
f(a-2,b);
}
now.pop_back();
}
int main(){
_3dDwnkq;
ll a,b;
cin>>a>>b;
if(prime(a+b)){
cout<<"3\n";
cout<<a<<" "<<a+b<<" "<<b<<"\b";
exit(0);
}
if(prime(abs(a-b))){
cout<<"2\n";
cout<<a<<" "<<b<<"\n";
exit(0);
}
f(a,b);
if(sz(pans)){
cout<<sz(pans)<<"\n";
for(auto x : pans){
cout<<x<<" ";
}
cout<<"\n";
}else{
cout<<"-1\n";
}
//
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1608 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
252 KB |
Expected integer, but "71" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2097 ms |
510132 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2066 ms |
524292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2115 ms |
507204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2112 ms |
505544 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2079 ms |
420 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2059 ms |
416 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2080 ms |
300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2083 ms |
308 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |