Submission #227483

# Submission time Handle Problem Language Result Execution time Memory
227483 2020-04-27T14:38:07 Z kshitij_sodani Lutrija (COCI19_lutrija) C++17
0 / 70
6 ms 432 KB
#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)>4){
			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-4,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
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 6 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -