Submission #202580

# Submission time Handle Problem Language Result Execution time Memory
202580 2020-02-17T05:54:45 Z Yojahuang Lutrija (COCI19_lutrija) C++14
0 / 70
10 ms 380 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

bool check(ll v) {
	if (v <= 1) return false;
	for (ll i = 2; i * i <= v; i++) {
		if (v % i == 0) return false;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(0),cin.tie(0);
	ll a, b;
	while (cin >> a >> b) {
		if (a == 2) {
			if (check(b - 2ll)) {
				cout << "2\n";
				cout << a << ' ' << b << '\n';
			} else if(check(b + 2ll)){
				cout << "3\n";
				cout << a << ' ' << b + 2ll << ' ' << b << '\n';
			} else {
				cout << "-1\n";
			}
		} else if(b == 2) {
			if (check(a - 2ll)) {
				cout << "2\n";
				cout << a << ' ' << b << '\n';
			} else if(check(a + 2ll)){
				cout << "3\n";
				cout << a << ' ' << a + 2ll << ' ' << b << '\n';
			} else {
				cout << "-1\n";
			}
		} else {
			if (abs(b - a) == 2) {
				cout << "2\n";
				cout << a << ' ' << b << '\n';
			} else if(abs(b - a) == 4 && check(min(a, b) + 2)) {
				ll p;
				cout << "3\n";
				if (a > b) p = b + 2;
				else p = a + 2;
				cout << a << ' ' << p << ' ' << b << '\n';
			}else {
				cout << "-1\n";
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 380 KB Output is correct
2 Incorrect 10 ms 248 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 248 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -