이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define endl "\n"
llo ip(llo aa){
llo j=2;
while(j*j<=aa){
if(aa%j==0){
return 0;
}
j+=1;
}
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
llo a,b;
cin>>a>>b;
llo stt=0;
if(a>b){
swap(a,b);
stt=1;
}
if(a==b){
cout<<1<<endl;
cout<<a<<endl;
}
else if(a>2 and b>2){
if(abs(a-b)>6){
cout<<-1<<endl;
return 0;
}
llo st=1;
llo co=0;
for(llo i=a;i<=b;i+=2){
co+=1;
if(ip(i)==0){
st=0;
}
}
if(st==0){
cout<<-1<<endl;
}
else{
cout<<co<<endl;
if(stt==0){
for(llo i=a;i<=b;i+=2){
cout<<i<<" ";
}
cout<<endl;
}
else{
for(llo i=b;i>=a;i-=2){
cout<<i<<" ";
}
cout<<endl;
}
}
}
else{
llo ind=-1;
llo so=1;
for(llo i=b;i>=max(b-6,a);i-=2){
if(ip(i)==0){
so=0;
break;
}
if(ip(abs(i-a))){
ind=i;
break;
}
}
if(ind==-1 or so==0){
cout<<-1<<endl;
}
else{
llo co=(b-ind)/2;
co+=1;
if(ind>a){
co+=1;
}
cout<<co<<endl;
if(stt==0){
cout<<a<<" ";
if(ind>a){
cout<<ind<<" ";
}
for(llo i=ind+2;i<=b;i+=2){
cout<<i<<" ";
}
cout<<endl;
}
else{
for(llo i=b;i>=ind+2;i-=2){
cout<<i<<" ";
}
cout<<ind<<" ";
if(ind>a){
cout<<a<<" ";
}
cout<<endl;
}
}
}
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... |