Submission #871628

# Submission time Handle Problem Language Result Execution time Memory
871628 2023-11-11T08:10:32 Z vjudge1 Lutrija (COCI19_lutrija) C++11
7 / 70
0 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector <int> ans;

int isPrime(ll a) {

	if(a < 2) return 0;
	if(a <= 3) return 1;
	for(int i = 2; i * i <= a; i++) {
		if (a % i == 0) return 0; 
	}
	return 1;
}

void finish() {
	cout << -1;
	exit(0);
}

int main() {

	ll a, b;
	cin >> a >> b;

	if(a % 2 == 0 && b % 2 == 0) finish();

	if(isPrime(abs(a-b))) {
		cout << "2\n" << a << " " << b  << "\n";
		return 0;
	}

	

	if(a % 2 && b % 2) {
		if(isPrime(a-2) && isPrime (b-2)) {cout << "5\n" << a << " 2 5 2 " << b << "\n"; return 0;}
		else finish();
	} 	

	if(a % 2) {
		if(isPrime(a + 2)) {cout << "3\n" << a << " " << a+2 << " " << b << "\n"; return 0;}
		else if(isPrime(a-2)) {cout << "4\n " << a << " 2 " << a << " 2" << "\n"; return 0;}
		else finish();
	}

	if(b % 2) {
		if(isPrime(b + 2)) {cout << "3\n" << a << " " << b+2 << " " << b << "\n"; return 0;}
		else if(isPrime(b-2)) {cout << "4\n " << "2 " << b << " 2 " << b << "\n"; return 0;}
		else finish();
	}
	



	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 436 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -