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>
using namespace std;
#define int long long
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int a, b;
cin >> a >> b;
bool tr1 = false;
if(a > b)
{
tr1 = true;
swap(a, b);
}
if(a == 2)
{
bool fl1 = true;
bool fl2 = true;
if(b == 3)
{
fl1 = false;
}
for(int j = 2; j * j <= (b - 2); j++)
{
if((b - 2) % j == 0)
{
fl1 = false;
}
}
for(int j = 2; j * j <= b + 2; j++)
{
if((b + 2) % j == 0)
{
fl2 = false;
}
}
if(tr1)
{
swap(a, b);
}
if(fl2)
{
cout << 3 << "\n";
cout << a << " " << a + b << " " << b;
}
else if(fl1)
{
cout << 2 << "\n";
cout << a << " " << b;
}
else
{
cout << -1;
}
return 0;
}
int t = a + 2;
while(t <= b)
{
for(int j = 2; j * j <= t; j++)
{
if(t % j == 0)
{
cout << -1;
return 0;
}
}
t += 2;
}
cout << (b - a) / 2 + 1 << "\n";
if(tr1)
{
for(int i = b; i >= a; i -= 2)
{
cout << i << " ";
}
}
else
{
for(int i = a; i <= b; i += 2)
{
cout << i << " ";
}
}
return 0;
}
# | 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... |