Submission #199480

# Submission time Handle Problem Language Result Execution time Memory
199480 2020-02-01T14:17:48 Z 44442 Lutrija (COCI19_lutrija) C++11
42 / 70
2000 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
long long a,b,am2,ap2,bm2,bp2;
bool pr(long long n){
	 for(int i=2;i*i<=n;i++){
	 	 if(!(n%i)) return 0;
	 }
	 return 1;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>a>>b;
if(pr(a-2)){
	 am2=1;
}
if(pr(a+2)){
	 ap2=1;
}
if(!am2 and !ap2){
	 cout<<-1;
	 return 0;
}
if(pr(b-2)){
	 bm2=1;
}
if(pr(b+2)){
	 bp2=1;
}
if(!am2 and !ap2){
	 cout<<-1;
	 return 0;
}
if(a==2){
	 if(bm2){
		 cout<<2<<endl<<2<<" "<<b;
     }
     else{
     	 cout<<3<<endl<<2<<" "<<b+2<<" "<<b;
	 }
}
else if(b==2){
	 if(bm2){
		 cout<<2<<endl<<a<<" "<<2;
     }
     else{
     	 cout<<3<<endl<<a<<" "<<a+2<<" "<<2; 
	 }
}
else if(ap2 and bp2){
	 cout<<5<<endl<<a<<" "<<a+2<<" "<<2<<" "<<b+2<<" "<<b;
}
else if(am2 and bp2){
	 cout<<4<<endl<<a<<" "<<2<<" "<<b+2<<" "<<b;
}
else if(ap2 and bm2){
	 cout<<4<<endl<<a<<" "<<a+2<<" "<<2<<" "<<b;
}
else if(am2 and bm2){
	 cout<<3<<endl<<a<<" "<<2<<" "<<b;
}
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2086 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2092 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -