Submission #244284

# Submission time Handle Problem Language Result Execution time Memory
244284 2020-07-03T13:48:37 Z Halit Lutrija (COCI19_lutrija) C++17
70 / 70
175 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

bool isPrime(long long n){
	if(n == 2) return true;
	if(n % 2 == 0) return false;
	if(n < 2) return false;
	
	for(long long i = 3;i * i <= n;i+=2)
		if(n % i == 0) 
			return false;
	return true;
}
int main(){
	long long a,b;
	cin >> a >> b;
	if( (a == 3 && b == 7 || b == 3 && a == 7) || (a == 2 && b == 2) ){
		cout << "3\n"<< a << " 5 " << b;
		return 0;
	}
	
	long long f = -1,s = -1;
	
	if(a != 2 && isPrime(a+2) )
		f = a+2;
	if(b != 2 && isPrime(b+2))	
		s = b+2;
	
	if((!isPrime(a+2) && !isPrime(a-2) && a != 2) || (!isPrime(b+2) && !isPrime(b-2) && b != 2))
		cout << -1 << "\n";
	else{
		cout << 2 + (s > 0) + (f > 0) + (a != 2 && b != 2) << "\n";
		cout << a <<  " ";
		if(f > 0)
			cout << f << " " << 2 << " ";
		else if(a != 2)
			cout << 2 << " ";
		if(s > 0)
			cout << s << " " << b;
		else if( b != 2 )
			cout << b;
			
	}
}


Compilation message

lutrija.cpp: In function 'int main()':
lutrija.cpp:17:14: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  if( (a == 3 && b == 7 || b == 3 && a == 7) || (a == 2 && b == 2) ){
       ~~~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 256 KB Output is correct
2 Correct 52 ms 256 KB Output is correct
3 Correct 147 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 376 KB Output is correct
2 Correct 52 ms 360 KB Output is correct
3 Correct 109 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 175 ms 256 KB Output is correct
2 Correct 49 ms 256 KB Output is correct
3 Correct 100 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 256 KB Output is correct
2 Correct 39 ms 384 KB Output is correct
3 Correct 38 ms 256 KB Output is correct