This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
vector<bool>vis(1005,0);
set<int>p;
for(int i=2;i<=1000;i++)
{
if(!vis[i])
{
p.insert(i);
for(int j=i*i;j<=1000;j+=i)vis[j]=1;
}
}
int a,b;
cin>>a>>b;
if(p.count(abs(a-b))){cout<<2<<'\n'<<a<<" "<<b<<'\n';return 0;}
int ans=-1;
for(auto u:p)
{
if(p.count(abs(a-u))&&p.count(abs(b-u)))
{
ans=u;
break;
}
}
if(ans==-1)cout<<-1<<'\n';
else cout<<3<<'\n'<<a<<" "<<ans<<" "<<b<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |